Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

.NET

The Rationale Behind ASP.NET MVC



In spite of its early Community Technology Preview (CTP) stage, the ASP.NET MVC Framework is extremely popular and is being talked a lot in blogs and community sites. Shipped as part of the ASP.NET 3.5 Extensions toolkit (along with other features such as ASP.NET controls for Silverlight and the ADO.NET Entity Framework), the ASP.NET MVC framework represents an alternative to the classic Web Forms model for ASP.NET pages and applications.

Six years ago, the Web Forms model received a warm welcome from the Web developers' community because it really made it simple to build pages and, more importantly, without requiring JavaScript and HTML strong skills. As a result, ASP.NET brought a number of C and C++ programmers to Web development, thus raising the quality of code and multiplying sites and applications. In a sense, ASP.NET disrupted the de facto association between the pair HTML+script and the Web. It worked just great for a few years.

In the long run, having a number of smarter and smarter developers at work on Web applications using modern and fully object-oriented languages such as C# raises some new issues as far as the design of applications is concerned. ASP.NET Web Forms has a number of benefits, but is not perfect either. In particular, ASP.NET Web Forms is lame on testing and separation of concerns (SoC).

I'm not here to say that SoC or testing is just impossible or impractical in the ASP.NET's Web Forms model. It's only that ASP.NET in conjunction with Visual Studio makes too easy to go the other way. Deadlines are always too close for any developer on the face of the earth; it's tempting to drop handmade controllers and presenters and place logic straight in the code-behind class.

The Web Forms model is centered around the user interface and the page. The ASP.NET page is made of server controls (often, rich controls) with their own object model and logic. An ASP.NET page is the center of the universe -- it's the view for the user, but also the container of most presentation logic, and maybe some business logic too.

Automated testing is hard because it's tough to decouple pages from the ASP.NET runtime and page lifecycle. Testing is not impossible but requires much more work than just preparing the test harness.

Adopting common industry patterns such as MVP and MVC is left to the good will of individual teams and developers. The Web Client Software Factory (WCSF) is just an attempt to provide a framework for SoC and testing; and it came out even too complex than required in most cases.

At the same time, a growing number of smart people in the industry are embracing new paradigms and practices. An example is the ALT.NET community. The ASP.NET MVC framework goes in the direction of providing an alternate model for building ASP.NET applications that is based on a different set of requirements: full SoC and, especially, test-driven development.

As of today, the ASP.NET MVC framework is physically separated from Web Forms and requires a modified runtime to work. It should be noted, though, that the ASP.NET MVC framework is fully extensible and it's only a tech-preview. It is far from being a released product with its own defined physiognomy.

Should you use it for development? No, because there's no Go-Live license and the product is not even in beta. Should you play with it? Yes, if you're just curious about different approaches to the building of Web applications and surely if you feel a bit uncomfortable with ASP.NET postbacks and viewstate.

The ASP.NET MVC framework changes the paradigm according to which you build Web applications. It may be shocking at first, if you're not prepared or don't really feel the need for change.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.