MVC is a very common pattern used in OO design to break the responsibilities into different components, Model, View and Controller. It is often used in the UI layer. We can easily find in its various implementations Java or Smalltalk. But this practice is not very common for .NET developers. Maybe it is not what Microsoft recommends. Microsoft has its own concept call page controller. Basically it treats the ASP.NET code behind as the controller itself. Code in codebehind can call service layer to get Model, then display onto the aspx page. This module is working fine under Microsoft’s IDE tool, Visual studio .NET. But the problem is page controller is bound with its view. It is not easy to separate. It is impossible for me to reuse the logic in the controller into Win form. For instance, the controller has some navigation logic which can be applied onto both win form and web form.
Currently my own approach is to apply MVP pattern in very web control in the page (I prefer to use web controls on the page) to delegate the business logic into service layer, and rely on a application level navigation controller to manage the page flow. The navigation controller is some type of sate machine implementation. You can find a excellent article by Michele Leroux Bustamante in MSDN. Andy Hunt has an article regarding this topic as well. For those developers who like to implement a MVC framework, there are some of the options:
1. Microsoft UIP. UIP came with Microsoft Application Building Block 2. But it seemed not as popular as its counterparts, like data building block or log building block. Still probably because of most of the developers don’t realize how important it is to separate the responsibilities and promote testability for the whole application. Again this core implementation is inherited from Microsoft page controller concept. You have to inherit its base page (default controller). Some resources which I recommend to read for UIP
CodeProject – User Interface Process Application Block (UIPAB)
CodeProject – UIPAB Part 2: MVC, UIPAB Essentials and Demo
UIP with PetShopDNG 2.0 (French)
2. MonoRail in Castle Project. MonoRail is inspired by Ruby on Rails. It implements a truly MVC pattern. The Rails engine sit behind as a Front controller to direct the request to the right page. Combined with Active Record, which is excellent implementation upon NHibernate, MonoRail can provide a very fast and maintainable development environment. Although Web Form is one of its supported view, it is more likely use Nvelocity. So its design is not as easy as in Visual Studio, also it lacks developer community support. Maybe it will change as Ruby on Rail gains such popularity recently.
3. Castle MVC Framework. It is very interesting project hosted in Castle. But currently it still in sandbox for reviewing. It is inspired by Microsoft UIP and MVC implementation from MonoRail. Actually the lastest version of Nshop2, sample application of iBatis .NET, is using this MVC framework. Similar with other MVC framework, it uses XML to define the mapping between the views and commands. The other advantage form Castle MVC is that it can be treated as facility to be plugin into Castle IOC container.
4. Maverick.NET. It was dead for a while. But some developers just pick it up recently. It releases its 1.12 version this January. Maverick .Net uses XML to configure sitemap. Its controller supports Pages and Controls. It does not have complete documents. But it does not too hard to figure out how to use it.
Does anybody can add more? :=)