Laila Lotfi

.NET tools Brand Manager & Simple-Talk Editor

Models, Views, and Controllers: ASP.NET MVC

Published Thursday, August 13, 2009 5:28 PM

The poor application programmer, chipping away contentedly in Winforms or Webforms, is often heard to groan whenever a new Microsoft product is announced. Silverlight (Groan), WPF (Groan), MVC (Groan) Hah! They caught you out there: what they have delivered with MVC is a design pattern, not a new technology, and it is free. The ASP.NET MVC 2.0 preview provides an interesting glimpse of how the 'framework' is developing.

It is good to see Microsoft get into the game of MVC architectures. Of course, there is nothing new about them; the technique of dividing the roles of an application into models, views, and controllers has been with us since the seventies. However, MVC gained a new relevance with web applications.

In any MVC design, such as Ruby on Rails, Monorail, Zend Framework, or Struts, the business logic is separated from input and presentation, with "Models" maintaining state. These models are responsible for maintaining the objects within the application and ensuring that they are represented in the relational database that underpins the application. A model will have "Views" associated with it. These Views, or projections, are the components needed to represent and display the model data in a way that the user can understand it and change it. "Controllers" manipulate the model, and respond to user input and interaction. When a model changes state, it notifies the views so they can reflect these changes.

This logical separation in application design makes a lot of sense with web design, though it works in a wide variety of information systems. The views become the rendered web pages, the controllers are the logical processes that happen in response to events and are enacted by scripting, and the models encapsulate the database entities and are maintained by the logical interface with the database.

Microsoft's MVC implementation, within ASP.NET, aims to be as unobtrusive as possible. You can carry on using Webforms and Dynamic Data, and existing ASP.NET features continue to work exactly as expected, although URL Redirection may require some additional work if you have an existing mapping technique.

ASP.NET MVC 2.0 looks as if it is going to be most suitable for large-scale applications. The concept of 'areas', separate groupings of MVC triplets, is going to ease the task of testing and building the components of large applications by providing some isolation. It extends DataAnnotation rules for input validation. It introduces the Templated helper. In the pipeline is client validation, and the handling of asynchronous Controller Actions.

Is ASP.NET MVC worth learning? I'd say yes, if you're the type of developer who wants full control over the application's behavior, you're engaged in a larger team development, and if you want a framework that is sympathetic to both TDD (Test-driven Development) and the separation of roles between developers and designers. However, it adds complexity, and lacks the rich event model and server controls of Web Forms. However, by their very nature, MVC architectures do not force you to adopt particular technologies: they're there if you need them but you're not forced to use them. If you like your applications lean and fast, then it is an approach that's worth considering.

Let me know what you think, I'd be really interested to hear some other opinions.

Cheers,

Laila

by Laila

Comments

 

Jason Haley said:

Interesting Finds: August 14, 2009
August 14, 2009 6:12 AM
 

TheCPUWizard said:

Laila,

It appears you may have confused MVC [Model, View, Controller] with MVP [odel, View, Presenter] design patterns.

Information on MVP patterns can be found here: http://social.msdn.microsoft.com/Search/en-US/?query=mvp%20design%20pattern&ac=2

Especially in an ASP.NET envrionment, the differentiation is key, as web based applications (even with AJAX/Silverlight/etc) do not have the tight coupling of UI with logic that most desktop applications have.


August 16, 2009 9:33 PM
 

mgaueca said:

Mi company develop banking self service applications (ATM) in Chile, and currently we use C# (WPF and Windows Workflow Foundation). So, this news is very interesting for us. Mauricio G. www.orand.cl
August 17, 2009 1:20 PM
 

James BlueBlood said:

can anyone tell me how to post the content in SIMPLE - TALK BLOGS
August 19, 2009 1:25 AM
 

Laila said:

Thanks for the interesting comment, TheCPUWizard. I’d agree that there is some confusion between MVP and MVC, though I would see MVP as being a variant of MVC that is more appropriate for rich client applications. I’d have thought that the MVC pattern was better suited for web development. I was guided by Phil Haack’s opinion, http://haacked.com/archive/2008/06/16/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx
‘This framework (ASP.NET MVC)  employs the MVC pattern rather than the MVP pattern because it does not attempt to emulate rich client development, and thus the MVC pattern is more appropriate.’

Laila
August 25, 2009 3:59 AM
 

Tony Davis said:

Tools such as Visual Basic (VB) and Visual FoxPro succeeded and became wildly popular because they provided...
November 26, 2009 6:06 AM
You need to sign in to comment on this blog

About Laila

I’m currently working as a Brand Manager in the .NET tools division of Red Gate Software. I also write the .NET Reflector newsletter, so if you have any feedback on the content you want us to cover, please do get in touch.



















<August 2009>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
Raw Materials: Command-Line Nostalgia
 Arthur finds philosophy deep in a dialog box. Read more...

Increasing Email Size Limits for your High Profile Users in Exchange 2010
 If you ever need to set up fine-grained rules to control the maximum size of messages a subset of your... Read more...

Product Review: Schema Compare for Oracle
 One of the more important tasks in the process of rolling out incremental developments to a... Read more...

Implementing the OUTPUT Clause in SQL Server 2008
 In retrospect, it was probably the inclusion of the OUTPUT clause in the MERGE statement that gave... Read more...

SQL Source Control: The Development Story
 Often, there is a huge difference between software being easy to use, and easy to develop. When your... Read more...