I checked out MVC months ago and didn't really get it.. but recently as I have become a better programmer I think it is making sense.. Here is my theory.. tell me if I got it Right
In the 90s for Microsoft Devs we had Classic ASP. This mixed VBscript and HTML on the same page. So you needed to create all the HTML yourself and mix HTML and VBScript. This was not considered Ideal. Then .NE开发者_开发知识库T came along and everyone liked it because it was similiar to event driven VB 6 style programming. It created this abstraction of binding data to ASP Servier controls. It made getting Enumerated data easy to get on the screen with one line. Then recently Jquery and SOA concepts are mixed together.. Now people think.. Why create this extra layer of abstraction when I can just directly use .NET as a data provider and use jquery AJAX calls to get the data and create the HTML with it directly .. no need for the Webforms abstraction layer..
Sowe are back to creating HTML directly like we did in 1999.
So MVC is all about saying Stop pretending like WEb programming is a VB6 app! Generate HTML directly!
Am I missing anything?
So I wonder.. for you people out there using MVC... is it the sort of things that once you get used to it you never want to go back to webforms??
God, I love MVC so much I don't even think words can capture how I feel :)
From time spent developing something viewpoint, I think that MVC and WebForms are equal.
In WebForms I would spend many hours fighting with DataGrid and other controls to do what I want and how I want it. And not to mention many many hours replacing UpdatePanels with jQuery from sites where it wasn't a viable solution anymore (performance wise).
In MVC I start with a blank slate and mold it to suit my needs. Need I say more?
EDIT: I just found http://aspnetmvc.componentart.com/
There are times when I wish I could just plug in a grid or datareader, hook it up and it just works, like I did in ASP.NET. Making applications in ASP.NET MVC is arguably more work. But then I remember all of the nitpicky things I had to deal with in ASP.NET, like ViewState, code-behind, and magic id's. The page rendering pipeline was so opaque to me that I never really got the hang of using the code-behind events properly.
ASP.NET MVC just seems cleaner and better organized, and I have far finer control over my application and its markup.
That said, I am glad that you can intermix ASP.NET and ASP.NET MVC pages, because there are some things you can't do in ASP.NET MVC, like use server controls. The new enhancements in ASP.NET 4.0 should make it easier for dedicated ASP.NET developers to produce applications with finer control over their markup.
I see it as Webforms are a quick and dirty way to get a site up and running with complex functionality. They allow the developer to not focus on a lot of the aspects of the controller by allowing them to use tool that have high overhead for the user (view-state, Update panels, etc.)
MVC even though takes a little more planning from the developers standpoint puts out a better product for the users with out a lot of "fine tuning" by the developer by trying to rework the webform-tool's functionality.
Not to mention MVC allows for easy TDD integration, obviously that's a plus for larger projects with multiple developers.
MVC would be the proper tool for most production high traffic sites, but Webforms could be the ideal tool for making quick prototypes and experimental stubs.
MVC is about giving you the benefit of designing your web app using the Model-View-Controller pattern i.e. separation of concerns, it's not about forcing you to write HTML manually.
I think that it makes you think more about what you are doing - in webforms it was very easy to drop an updatepanel in and have an AJAXy style page without really thinking about performance. With MVC, it's much cleaner to make focused AJAX calls via jQuery to single controller actions - everything is much lighter.
There is als no page event structure to worry about and no Viewstate to rely on as a crutch - I think that this in general pushes you towards better code.
Some of us have to. I work with a number of different client, and while my most recent project was using MVC, I'm now back looking at an application suite that includes both Webforms and classic asp.
And all I can say is that the transition back is very, very painful.
精彩评论