Infrastructure is hard.

When you’re developing a new app, it is often daunting to decide how you’re going to structure the app.

The MVC design pattern is a well tested, and time-honored, architecture for applications of all types.

In the last few years the pattern has gained recognition through Microsoft’s ASP.NET. this is not the only technique for creating an MVC application. The MVC pattern can be implemented in any object-oriented programming language.

Today I bring you SimpleMVC. SimpleMVC is a new package for C sharp developers that provides an API they can use to create great MVC based applications. SimpleMVC uses an asynchronous programming model to allow for usage in any kind of application such as WPF, ASP.Net WinForms and even Unity or Xamarin.

MVC is not a flavor of the month. Unlike MVVM, it is capable of creating applications that are cross-platform as well as cross UI technology. Models, View definitions, and Controllers are each encapsulated so that they can be reused across different applications that need the same business logic.

SimpleMVC uses an Adapter pattern to allow models to be transported across not only platforms but data access types. Because of this you could use MS Sql Server, Oracle, or even simple mock Frameworks to provide data to your application all without changing a single line of code in the controller the model or the View.  To accomplish this I also created SimpleDI or Simple Dependency Injection.

SimpleDI allows you to create object definitions in any way you decide to define the dependency.  For example you may use the built-in JSON formatted dependency definition or you may create a hard-coded dependency definition.

All of this is about flexibility.


The combination of SimpleDI an SimpleMVC allow you to create cross-platform, cross-application, and cross-technology implementations of applications that will grow with you as you need them to grow.


INTRODUCTION: The Gang of Four were pretty smart folks. They gave us a lot of design patterns to use to make better application architectures. One of the patterns they gave us was the Facade, which is generally used to provide common functionality for objects that don’t necessarily have a polymorphic purpose for the object. In C# we use static classes to build facades, which is great. Facade classes allow you to group together similar functionality and because the classes and methods are static, there is an expectation that they should work on any instance of the object(s) being manipulated.

Extension methods take the Facade one step further. Instead of having to reference a Facade class specifically, the extension methods bring the facade methods right to the class(es) they apply to. You might be asking right now, “What is an extension method?” Extension methods are defined as static methods of static classes that receive the context of a single object instance that allows you to present the functionality of the method as an extension of the object.


public static class MyExtensionFacade
    // Normal facade implementation
    public static void IncrementInt32ByDecimal(out int source, decimal value)
        source += (int)(value + 0.5m);

    // Extension Method
    // Notice the use of the this keyword, it defines the object that the
    // extension method works on.
    public static void IncrementByDecimal(this int source, decimal value)
        IncrementInt32ByDecimal(out source, value);

public class Program
    public static void Main(string[] args)
        int i = 10;
        decimal d = 15.75m;

        // Call facade method as normal.
        MyExtensionFacade.IncrementInt32ByDecimal(out i, d);

        Console.WriteLine($"i = {i}");

        // Call as extension method

        Console.WriteLine($"i = {i}");

CONCLUSION: As you can see from the example, the extension method is much simpler to call and makes your code cleaner. As a matter of fact, the entire LINQ framework is a series of extension methods. They can be a very valuable and powerful arrow in your quiver of Ninja tricks.