I had a client that already had ASP.NET Webforms and was wondering on whether or not to switch to MVC. So I asked the question - is what you have working? If so, why do you feel the need to change? Their answer - because they heard it was the latest and that is what they should do.
M-V-C Pattern
Well, MVC is considered by some to be the latest but it has been around for several years with .NET. MVC is a pattern - which has been around for longer than Microsoft. Patterns are designed for a certain usage. They are not an "apply to all situations" methodology. So whether you choose Webforms or MVC - depends on many factors including resources, experience, time, money, features, and so on.
ROI
Porting an entire application just to be using the latest doesn't mean it gives you the best ROI. There is nothing intrinsically wrong with Webforms - it is a pattern. Webforms have their place. However, if porting it over or re-writing it streamlines, enhances, and reduces your overall maintenance and gives you a competitive edge - then by all means crunch the ROI.
Comparing ASP.NET vs. MVC
This is a simple table of some of the pros and cons of each implementation of methodology. This is a light representation, as each item can be worded out for more explanation (later).
WebForms | vs. | MVC |
Views tightly coupled to logic | View and logic separate | |
User Controls | Partial views | |
Automatic View State | No View State | |
Controls generate HTML | You generate HTML | |
Harder to test | Easier to test | |
Mobile devices require multiple pages | Handle it how you want | |
Page Lifecycle | No page lifecycle | |
Postback | No postback | |
Update controls | No update controls | |
Faster learning curve | Slower learning curve | |
Not JavaScript friendly | JavaScript friendly | |
More 3rd party controls | Gaining popularity | |
Server controls | HTML Helpers | |
Master Pages | Layouts | |
Less control | More control | |
Since MVC is built on the web framework it shares some of the same core features such as:
WebForms | vs. | MVC |
Session State | Session State | |
Caching | Caching | |
Profiles | Profiles | |
Security | Security | |
Membership | Membership | |
Tracing | Tracing | |
Configuration | Configuration | |
Health Monitoring | Health Monitoring | |
Localization | Localization |
MVC Approach
Choose the MVC approach if:
- You want more control over HTML
- You want or plan to do Test Driven Development
- You want SEO based URLs
- You want higher web standards and accessibility
- You need tight control and plan to use JavaScript heavily
Choose the Webforms approach if:
- You want rich web controls
- You want state oriented web pages
- You want event-driven web pages
- You don't want or need as much control over the rendering of the HTML
- You don't or need heavy JavaScript framework integration
If you are an ASP.NET C# Webforms developer - jump in and do MVC. You will find that you like the control. Because deep down inside - you like the control!
0 comments:
Post a Comment