In the late nineties developers on a Microsoft stack would have been using Active Server Pages (ASP) for server side scripting and would have had to have a reasonable understanding of web development i.e. the stateless nature of the web and use of the HTTP protocol in general. At that time, Microsoft had a large network of Visual Basic developers developing windows based software. ASP.net, first released in 2002, provided a path for these developers to get into the rapidly growing space of web development with a reduced learning curve.
This reduced learning curve was achieved by abstracting the stateless nature of the web using mechanisms such as viewstate and postback. ASP.net allowed controls to be dragged to the page, code behind allowed events to be added to these controls, encouraging an event driven GUI approach to web development. This provided a development environment familiar to those migrating from Windows desktop development but had some drawbacks. This level of abstraction meant that developers where removed from the stateless nature of the web. Code behind classes, introduced to reduce the amount of code mixed in with HTML on the web pages, often became tangled, with business logic being mixed in with UI related code.
With the release of ASP.net MVC Microsoft embraced these advances in web development and offered developers on the Microsoft stack an alternative to ASP.net web forms. ASP.net MVC now on version 3 with version 4 in beta offers the following advantages.
Separation of concerns
Core to the ASP.net MVC framework is the design pattern behind the acronym in its name, Model, View Controller. Separation of concerns is fundamental to this pattern, which can be summarised as follows
Model: The model contains the business logic of an application, retrieves data and enforces validation rules
View: The view contains the user interface of an application
Controller: The controller classes manage the control flow. These interact with the model and return appropriate views.
Software always changes. The separation of concerns provided by this pattern allows for greater flexibility, thus making change less painful. For example, a view can be changed independently of the controller and models. This also allows different developers to work on different parts of the application in parallel.
ASP.net MVC encourages the use of RESTfull URLs. These URLs are human readable, SEO-friendly and discoverable, for example
One of the main advantages of SOC mentioned earlier is that it facilitates Test Driven Development (TDD). With the adoption of Agile methodologies TDD has become an essential part of web development. Tightly coupled code is difficult to test. ASP.net MVC encourages loosely coupled code which enables TDD.
Web forms or MVC?
Of course web forms have their place; they may provide a better fit for developers with less experience of web development as it’s more like windows forms development; they are arguably better for Rapid Application Development (RAD), though this has a cost when it comes time to change and maintain.
Microsoft fully supports both approaches and plan to do so for the foreseeable future so either approach is valid. At Dataworks we like what we’ve seen with ASP.net MVC and most of our new web application development is adopting this approach.
- Back to Blogs