It's still a debate that which is better, the technology which was introduced by Microsoft two decade back as an savior of web development (Web forms) or the framework wrapped up with some good pattern introduced after wards (MVC).
We will discuss both of them in a way to present adequate guidance to not to CHOSE which one is better but to DECIDE which one will be better in what circumstances and situations.
Preface
Before starting this article/blog let us understand some facts about .NET, Web Forms and MVC
- MVC is not separate from .NET framework its a part or you can say extension on the .NET framework itself.
- Web Forms and MVC are mainly architectural patterns and has some specific feature to enable or force the developer to use some predefined rules.
- Non of the technology is going to yeild better results if you do not use them efficiently with full control over it.
- It's us the developer who makes the technology usable whether its VB or .NET CORE.
- The technology you uses impresses no one. The experience you create with it is everything.
The History
1999
- Microsoft ASP.NET came to action in 1999, when it was tentatively named ASP+. At that time, building a Web application on the Microsoft platform was a matter of assembling a bunch of Active Server Pages (ASP).
2002
- Later in 2002 version 1.0 of .NET framework was released with feature such as Support for Object-oriented Web application development and Use of DLL Class libraries.
I will not go in to feature lists but will only show new versions released, intent is to show the side by side advancements of both the technologies.
13 March 2009
- This is the day when MVC 1.0 was released. from now it doesn't mean that Microsoft has stopped investment and further advancement on Web forms its still running.
2010
- Parallel extensions and other .NET Framework 4 features on web forms specifically The two new properties added in the Page class are MetaKeyword and MetaDescription.
- MVC 2 was released
2012
- Parallel extensions and other .NET Framework 4.5 features
- MVC 4
2015
- .Net framework 4.6 released with many bug fixes of server controls mainly for grid views.
- ASP.NET MVC 6.0.0-rc1 which was a community released and is later released in ASP.NET CORE along with Web Forms.
2017
.NET Core revision was released with both Web Forms and MVC templates under VS 2017. Here is a snap shot of Visual Studio which has support for both MVC and Web forms, apart from this CORE web application has a totally different architecture.
So from the aforementioned history we have seen that neither of the web frameworks are to be replaced
by the other nor are there plans to have them 'merged' into a single framework.
Continued support and development are done in parallel by Microsoft and neither
will be 'going away'.
If neither are going away that means both are equivalently efficient to full fill our requirements.
Comparison
Every web framework has advantages and drawbacks, which we can consider to decide and compare according to our need. Lets start with the technology part.
Technical ponder
ASP.NET Web Forms:
- Supports users prospective- Gives the illusion of that web application is aware of what the user is doing i.e. wizard functionality is little bit easier to implement, hide most of the complexity while development.
- Rapid Application Development (RAD)- The total focus and intent of web forms was RAD right from the beginning. Over all it comes down to the level of expertise of the developers but personally it's easier to learn and jump start developing applications.
- Mature Control toolbox- ASP.NET Web Forms offers a much greater and more robust toolbox (web controls) whereas MVC offers a more primitive control set relying more on rich client-side controls via jQuery (Javascript).
ASP.NET MVC:
- Separation of Concern (SoC)- The code in MVC is very clean, it forces the developer to use a pattern which helps it to scale in terms of performance, but this can be easily achieved in web forms also with a better and clean architecture such as MVP.
- Test Driven Development (TDD)- As most of the design is based on interfaces. (Again a bad developer can mess it to hell)
- SEO friendly URL design.
- No View States, a good design decision to make pages lighter, which can be achieved in ASP.NET web forms 4.0 also as it supports control level client ID and you can disable the view state of a particular control or even pages. though it will kill the intent of some web forms basic concepts like partial post backs.
- Rich UI support, JS libraries can be used easily, where as in web forms its quite difficult to manage.
- Support for Entity frame work, though EF supports web forms but it easier to maintain with MVC. Maintainability is still a question while using EF :) .
"Is MVC faster?"
Yes by default as it lacks view states and has markups which are clean, the rendering time is a big factor.
Web forms are not bad when performance is considered it encourages many bad practices but with good practice it can be more efficient in hands of a good architect and developer.
The business and other prospect
- Learning curves in MVC can be thought of as a leaning tower while making decisions on transferring to MVC from web forms, learning MVC is not that easy for web forms developers, I'm not saying it's impossible but to switch to requires time for developer to get mature on it. (some may not agree with this).
- If you have a huge website developed in web forms,then its a big no to switching to MVC unless until all your module leads and developers are familiar with MVC architecture, pattern and code.
- If you are developing a new application then you should go with MVC, to give that technology peace to your hungry team. Again considering that time & money up curve which will cost in training.
- In business prospect employee satisfaction is a measure aspect, if you not give the technology to team who were asking for it, you may loose some of your good men.
The Facts
- Web Forms is true RAD (suppose quickly binding data to a grid or drop down list in web forms and in MVC)
- Web forms are hard to test.
- MVC has more control over HTML, but web forms can also meet it by just using HTML controls which will kill the intent of rich tool box and RAD.
- MVC is not the only way to achieve SoC in .NET.
- Web Forms allows you to learn as you go.
- View states can be efficiently managed in web forms.
- Web Forms was designed to abstract the web mechanism.
- MVC exposes web architecture.
- MVC was designed encapsulating TDD and dependency injection.
- MVC enforces and promotes better designs.
- MVC lacks component model (I think which is not gonna happen as it is as it is).
- MVC was not created to replace Web Forms (not at all).
A decisive conclusion
According to an email reply from Scott Guthrie (Scott Guthrie invented the
MVC framework for ASP.NET and many others), "Different customers look for different programming
approaches, and a lot love WebForms and think it is great. Others love MVC and
think it is great. That is why we are investing in both."
We have seen pros and cons of both the approaches. The concusion from my point of view is that neither of MVC or Web Forms are bad, it's up to you in which you can create a better application, don't just jump in to the bandwagon for the shake of hype.Before switching to new thing, grow your self and be comfortable in that technology of your choice and interest. No software magic exists, and none is yet supported by the ASP.NET platform.
Hope you had liked these thoughts, these are taken references from many debates and Q&A forums and obviously the Microsoft forum/blog and Channel 9.
Comments
Post a Comment
Please do share your thoughts.