InfoQ

News

Model-View-Controller framework for ASP.NET in the works

Posted by Hartmut Wilms on Mar 17, 2007 08:50 AM

Community
.NET
Topics
.NET Framework
Tags
ASP.NET
At the MVP Summit Scott Guthrie presented a prototype for a Model-View-Controller framework, which might make its way into ASP.NET, in a special meeting arranged by Jeffrey Palermo.

The Model-View-Controller framework is centered around the Controller. In the Java world Struts is a very popular example of an MVC Web Application Framework. The general idea is that the controller is responsible for the navigational code, i.e. it controls the application flow. The view simply renders the information stored in the model. Although MVC provides a certain level of separation of concerns, the view is often tightly coupled to the model. On the other hand the application flow is separated from the view, thus providing better means of reusing views as well as a cleaner web client implementation.

Jeffrey Palermo describes how the MVC framework prototype works:

With Scott's prototype, there is a new handler factory that infers from the URL which controller to instantiate and load. The controller then decides what to do with the request. The controller can load a view (.aspx file) and let it render. The view can access properties of the Controller. The ASP.NET lifecycle and control model and still be used in the view, or you can let the Controller render a view of customized templates. Either way, the Controller is in control.
Besides supporting separation of concerns, MVC allows for an easy way of unit testing web clients. The flow of actions can be tested without instantiating (real) views; mock views can be used instead.

Joost gives some explanation of the Model View Controller pattern in web applications in his article, also naming the pros & cons:
  • What's so useful about it
    • Separation of requests and pages
    • Views are dumb
    • Shielding of the Model implementation

  • Problems and limitations
    • What goes where
    • Coupling between View and Model
    • Lots of objects
Today the Model-View-Presenter pattern is used for separating model, view and application flow in the ASP.NET world, e.g. in the Web Client Software Factory. Sometimes MVP is seen as an improvement of MVC, making use of its strengths and at the same time avoiding its disadvantages. Martin Fowler provides a nice overview of current GUI Architectures. Within the article he explains the different paradigms for developing GUIs:
To approach MVP I find it helpful to think about a significant mismatch between two stands of UI thinking. On the one hand is the Forms and Controller architecture which was mainstream approach to UI design, on the other is MVC and its derivatives. The Forms and Controls model provides a design that is easy to understand and makes a good separation between reusable widgets and application specific code. What it lacks, and MVC has so strongly, is Separated Presentation and indeed the context of programming using a Domain Model. I see MVP as a step towards uniting these streams, trying to take the best from each.
Concerning the value of the MVC framework for ASP.NET Jeffrey Palermo concludes:
This is very cool, and ScottGu is headed in the right direction. I'll vouch for that. We're going to end up with a new ASP.NET paradigm that so much easier to work with and, most importantly, easier to test!
What are your experiences with Web Application Frameworks, the MVP or MVC pattern and what do you think of MVC for ASP.NET?

7 comments

Reply

Monorail??? by Rob Eisenberg Posted Mar 17, 2007 11:05 AM
Re: Monorail??? by Hartmut Wilms Posted Mar 17, 2007 11:34 AM
Re: Monorail??? by Ricardo Redder Posted Mar 17, 2007 12:49 PM
Re: Monorail??? by David Li Posted Mar 18, 2007 1:37 PM
Re: Monorail??? by Jeff Santini Posted Mar 20, 2007 9:12 AM
Re: Monorail??? by Hartmut Wilms Posted Mar 21, 2007 4:09 AM
Is this the new Rails-style framework people have been whispering about? by Obie Fernandez Posted Mar 17, 2007 9:31 PM
  1. Back to top

    Monorail???

    Mar 17, 2007 11:05 AM by Rob Eisenberg

    Sure. This is moving in the right direction. However, it's still another layer built on top of a poor abstraction. Why not just use Castle's Monorail. It already has all of these features plus tons more. It's tested and proven in the field. It's going to take MS several years before it can catch up with what is already available TODAY in open source frameworks (Castle-Monorail, NHibernate, MbUnit, RhinoMocks, etc.)

  2. Back to top

    Re: Monorail???

    Mar 17, 2007 11:34 AM by Hartmut Wilms

    You're right. Monorail is surely a great framework. But this opens another completely different discussion. The same question might have been asked (and was) concerning NUnit, MbUnit, Log4Net, and several other great OSS tools.

  3. Back to top

    Re: Monorail???

    Mar 17, 2007 12:49 PM by Ricardo Redder

    Definitely Castle is the best framework available for .NET, but it still needs lots of improvements, even though... it's great, and it does MVC, as well as many other things.

  4. I heard at QCon from someone high up in the dark empire that it might be codenamed Blink...

  5. Back to top

    Re: Monorail???

    Mar 18, 2007 1:37 PM by David Li

    The reason is because in a lot of high level corporate environments, open source products are no-no.

  6. Back to top

    Re: Monorail???

    Mar 20, 2007 9:12 AM by Jeff Santini

    But in alot of others they are not. Certainly in the Java world I have never worked on a project in a big corporate environment without some OSS. Hibernate, Ibatis, Spring, Webwork, Freemarker, Velocity are all de rigeur in the high profile Java projects I have been associated with. Have also been involved with NHibernate and Neo being used in .Net projects

  7. Back to top

    Re: Monorail???

    Mar 21, 2007 4:09 AM by Hartmut Wilms

    The main reasons for .NET OOS tools being rejected by "big companies" are that the Microsoft community's activities in the field of OSS development has been weak in the pre .NET era and that Microsoft provides tools on their own instead of supporting the OSS frameworks. Sun supports Java OSS development, e.g. they are supporting Tomcat as a reference implementation for some of their J2EE specs. There are reasons for both the Microsoft and the Java way of handling OSS development.

Exclusive Content

Typemock: Past, Present and Future

Eli Lopian of Typemock answers a few questions on Typemock origins and where Typemock is headed.

Agile in Practice: What Is Actually Going On Out There?

Scott Ambler talks about actual data resulting from surveys made during 2006-2008, showing how Agile is perceived and implemented within organizations.

Building Smart Windows Applications

From QCon 2008, Daniel Moth presents on using Visual Studio 2008 and .NET 3.5 to create compelling rich Windows applications.

Joshua Kerievsky about Industrial XP

Joshua Kerievsky, founder of Industrial Logic, talks about Industrial Extreme Programming which extends XP by including practices dealing with management, customers and developers.

Jeff Barr Discusses Amazon Web Services

Amazon Web Services (AWS) Evangelist Jeff Barr discusses SimpleDB, S3, EC2, SQS, cloud computing, how different Amazon services interact, origins of AWS, AWS globalization and the March AWS outage.

More Than Just Spin (Up) : Virtualization for the Enterprise and SaaS

Cloud services have helped bring virtualization to the forefront. Its full power however, also includes other benefits such as high availability, disaster recovery, and rapid provisioning.

Ruby Beyond Rails

John Lam talks about his path to dynamic languages, some of the problems of making IronRuby run fast, and how the DLR helps with implementing languages.

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.