views:

138

answers:

4

is there any particular website that would make sense to use MVC versus webforms.

what would be the decision process in deciding between these options?

+1  A: 

I wouldn't say a type of website would be better for either to but more or less the needs of a website.

If you need a website that's can be thrown together very quick without a large amount of code and you don't care about HTML markup. Than WebForms is the way to go.

If you're a control freak and you want control over everything that's happening and the markup being generated. Than MVC is probably for you.

MVC is less of an abstraction of the HTTP model meaning a lot less is done for you. It doesn't hold state like WebForms' ViewState.

Chad Moran
A: 

The decision process for me is pretty simple. All new development will be done with ASP.NET MVC. Existing sites that need minor modifications will continue to be WebForms. Existing sites that need major modifications will be candidates to move to MVC.

The basic reason that I'm making the switch has to do with testability and design. IMO MVC web sites are significantly more testable. I can test everything but the view logic with unit tests and, by using and testing HtmlHelper extensions I can even test a fair amount of view logic. With WebForms I had to jump through lots of hoops to test codebehind and as a result left a lot of the app for manual testing.

I also feel that the architecture is simply better from a design standpoint. Because of the clear separation of concerns it's less tempting to insert business logic in the wrong place (e.g., the view). It makes conceptualizing and understanding the application much easier. I'm also able to reuse even view code with less effort because I don't have extraneous bits of logic from other layers hanging around to get in the way.

The only real downside I see at present is that it's not as mature and you don't already have as many reusable components built for it. I expect that to change, though, over time. Also, even though it is possible to intermix MVC with WebForms, I don't see retrofitting existing apps as a viable alternative unless there is significant other work to be done. Again, just my opinion, but I would rather start from scratch with MVC than try and get an existing app to work with it. I suppose it would depend on the size of the app, but anything with any significant number of pages is going to have a lot of routing exceptions.

tvanfosson
+5  A: 

There is a lot of enthusiasm around MVC right now, but if you are starting a new dev project right now I'd still recommend that you carefully consider before jumping on the MVC train just yet.

For most dev teams on any non-trivial project, there are some serious considerations. Here are the ones I find most relevant:

  • MVC requires much more skill from your developers. They will need significant expertise in the inner workings of HTML/CSS as well as a good understanding of how HTTP works. For the client side code they will need strong javascript and JQuery skills, and on the server side an advanced grasp of OO principals. And if you plan to get the most from MVC, experience with unit testing and mocking frameworks too.

  • The MVC 1.x framework currently doesn't get much in the way of RAD features from Visual Studio. You get a text editor and intellisense, but that's about it. No wizards, no drag-n-drop components, no property editors, etc. While this isn't really that bad, it does often mean that building non-trivial UIs will take significantly longer, especially for less experienced developers.

  • MVC is very new, and so code samples, tutorials, and sample apps are very hard to come by and tend to be very limited in scope. Documentation is also a bit thin at present.

  • Perhaps the biggest drawback to the MVC framework is the lack of an established and mature 3rd party market around it. With web forms there are tons of very advanced UI suites and components on the market and tons of open source projects you can borrow from.

  • For many apps, especially business apps the lack of 3rd party reporting, charting, and advaned grid controls for the MVC framework alone should be a major concern.

MVC is fantastic, and I highly recommend it if you are in a position where you can use it. But there are real costs and risks for any significantly complex project that may keep you on web forms for a while longer.

I do expect that the next major version of MVC will probably address many of those issues, especially with the lack of RAD features. I also expect that the enthusiasm around MVC will bring a lot of 3rd party support to the platform too. But it will take some time for all that to get well established.

Stephen M. Redd
Good points, although without wishing to be a complete pedant, I guess you mean, "ASP.NET MVC is very new" - MVC itself originated ca. 1979 at PARC.
Rob
+1  A: 

I spent the last 4 weeks reading the available material on MVC and doing the various videos and tutorials. Today I started working on an actual application (with a client awaiting to see results some time soon). I agree with the previous answers (an awful lot to learn, many many new concepts, little in lieu of 3rd party components). Still I am glad I have spent the time learning mvc. - You have to overcome your fear of row html/css/jscript which are hidden with webforms. It takes time to get used to the html tags. Once you do you will find out about the possibilities available. You will unlikely miss tags. - If you have no experience using unit tests, then I think that mvc provides for a great introduction into the possibilities that come with unit testing. - OO is much more present and "obvious" within mvc.
- Separation of concerns is possible and natural. You will not miss mixing gui and business logic in an aspx.cs file.
- No more page_load (and the n different stages). If you never quite liked asp.net's databinding, you will love mvc. I am happy not to have to do it ever again!

Cons: - It is slow. At the beginning it is very slow. Things that take little time in webforms, can take a lot of time with mvc.
- Not having pages any longer is also a massive change. But once you "internalize" this (time...), you will not miss the pages. - An O/R Mappers is also needed. One more thing to learn. - There is a lot to learn and get used to, should you be interested in getting the most out of the framework. MVC is only half-mvc without unit testing. Unit testing without a mocking framework is not really possible, so you must learn that too. By the time you think you are half-way through with unit testing, you see the need to automate parts of your work, nant must be learned as well. It is just endless.... But again, once you start using these technologies you will wonder how you ever managed without.

Nasser