Friday, July 30, 2010

Choosing Between WebForms and MVC

Now that Asp.Net is much more mainstream at work, the question is asked time and again as to which one should be used while developing a Web Application. One possible way to answer this question is to do a rudimentary SWOT analysis of both the frameworks.
Following is the SWOT analysis for each:

mvc_swot
forms_swot
Based on the above, a broad over decision flow can be created as shown in the following picture.
decision
Everything apart, I think there are two major considerations for choosing between the two:
  • Test Driven Development – life would be MUCH easier using MVC while following TDD.
  • Data Driven Application – life would be MUCH easier using WebForms if the application is data heavy.
Of course, there are no rights or wrongs, and every application can be written in both frameworks. In fact, you can even have a hybrid approach, where you can write some part in WebForms and some in MVC (theoretically).
What’s your experience?
Here’s the SWOT analysis in text form:
Asp.Net MVC SWOT
Strengths
  • Provides fine control over rendered HTML.
  • Cleaner generated HTML.
  • Superior separation between UI and code.
  • Easier to unit test.
  • Can support multiple view engines.
  • By default uses RESTful interfaces for URLs – so better SEO.
  • No ViewState (this may also be a weakness).
  • Typical size of page is small.
  • Easy integration with frameworks like JQuery.
Weaknesses
  • Not event driven, so maybe difficult for people who know only Asp.Net Webforms to wrap their minds around it.
  • Third party control library support is not that strong.
  • No ViewState(this is also a strength).
Opportunities
  • Allows for Test Driven Development (TDD) – it is built with TDD in mind, so its much easier to write unit test cases, mock objects, and to intercept the program flow.
  • Allows for reuse of the same models to present different UIs and Interfaces.
Threats
  • Bigger ramp-up and training time required for developers with no or little experience in web application development.
Asp.Net WebForms SWOT
Strengths
  • Provides very good RAD development capabilities.
  • Great designer support in Visual Studio.
  • Ease of development for data-heavy LOB applications.
  • Very rich control libraries and third party vendor support.
  • A familiar event-driven model when compared to Windows Forms development, and so easy for developers to pick up.
Weaknesses
  • UI logic coupled with the code, and thus is hard to separate.
  • Harder to unit test, so difficult to employ TDD.
  • Heavy page sizes due to view state management.
Opportunities
  • Great at creating quick prototypes for business applications. This comes in very handy when trying to show quick Proof of Concepts to clients.
Threats
  • Harder to adopt to various UI views despite the various frameworks available (master pages, Themes, etc.). 

source

No comments:

Post a Comment