ASP .Net MVC – patterns of the Microsoft framework

Read more on RaduPoenaru.com about ASP .Net MVC

Read more on RaduPoenaru.com about ASP .Net MVC

These days I decided to dig a little more into ASP .Net MVC. At a first glance, resembles very much with Ruby on Rails – although same idea, I find it more close to my stile. Maybe I am biased towards it because I am already working on Microsoft stack for the last 9 years. The framework is created by Microsoft employees and it is freely available for download, including sources, on Codeplex. That says pretty much about the open source initiative inside Microsoft. Bravo!

Another thing that I liked a lot is the fact that in order to start development, using a freshly installed machine or one without any Microsoft development tools, one needs only to download and install Web Platform Installer, which will continue with the tools download and all the required settings. The developer can grab a cold beer and check his mail or start learning about the Microsoft’s MVC implementation.

Yes, it is the Microsoft supported implementation of a well known pattern by several of its employees, started and continued as an opensource initiative.

The original MVC pattern

The pattern was created at the end of seventies by Trygve Reenskaug, who was part of the research team at Xerox PARC, as part of the Smalltalk system. The pattern is quite simple and separates the key components of a system into 3 distinctive areas (quoted from Wikipedia):

In addition to dividing the application into three kinds of components, the MVC design defines the interactions between them.[8]

  • controller can send commands to its associated view to change the view’s presentation of the model (e.g., by scrolling through a document). It can also send commands to the model to update the model’s state (e.g., editing a document).
  • model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. A passive implementation of MVC omits these notifications, because the application does not require them or the software platform does not support them.[9]
  • view requests from the model the information that it needs to generate an output representation.

The Microsoft version – ASP .Net MVC

Among all flavours of MVC and its brothers (Model View ViewModel, Model–view–adapter, Model–view–presenter, Observer pattern, Presentation–abstraction–control, Hierarchical model–view–controller), the Microsoft implementation of the pattern in .Net MVC framework is based on Front Controller pattern and Model 2 patterns [“Programming Microsoft ASP.NET MVC” by Dino Esposito]. Front controller pattern involves a centralized dispatcher that handles all incoming requests towards a component in the pipeline to service that request. Since we’re in patterns area, closely related is the Page Controller. As opposed to Front Controller, the Page controller (implemented in WebForms) manages the incoming requests on URL basis = the reuse of the code is quite limited. Thus, you have to create and maintain several individual pages and their underlying logic as opposed to focus on a central controller and several views which will be used and reused as necessary.

Difference between Page controller and Front controller patterns

See original image and article on http://www.developerfusion.com/article/9450/controller-patterns-for-aspnet/

Leave a comment

Your email address will not be published. Required fields are marked *