views:

294

answers:

4

This have puzzled me for a while, I would like to know why -from a programmer point of view- I should take the time to learn MVC and where do I need it, and I am not talking about theoretical models, I am asking how can MVC make my life easier and where?

A: 

This has been discussed a number of times here on SO. See this, for instance.

Long story short: generally speaking, WebForms suck big time compared to ASP.NET MVC. Of course, there is no silver bullet and there are cases where WebForms will be more than appropriate, but the whole model of WebForms, in addition to being a terribly leaky abstraction, is very alien to how HTTP works. Plus, used unwisely, it can (an will) kill your performance.

MVC, on the contrary, is very close to the bare metal and to the HTTP in general, so this allows you to build true Web apps.

Anton Gogolev
I don't like Web forms but I think you're terribly bashing it. I believe it's a marvelous piece of engineering. Abstracting HTTP even at this level is VERY HARD. Indeed Web forms make building many Web apps a real breeze for beginners. I mean while Web forms might suck at building lots of Web apps, it's a fantastic attempt whatsoever.
Mehrdad Afshari
It may be a 'real breeze' for beginners, but once you get to any non-trivial sized application, you run into a lot of performance balances/maintenance balances. Do you use Viewstate? Store Session State in DB? Forgo the Microsoft Way? Use Object DataSource or DataSets/DataTables? Or bind your POCOs instead?
George Stocker
A: 

In Classic webforms, you're stuck doing one of two things:

1) The Microsoft method, which is Drag-and-Drop, but is hellacious to extend do anything past simple datasets/Datatables.

2) Forgoing the Microsoft Way, and coding around the limitations of Datagrids, Listviews, and the myriad of other controls you're given to do your job.

The problem really is: Once you get out of that sphere of Drag-and-drop, you're spending more and more time coding around limitations than you are adding features.

With MVC, it forgos the ease of the initial setup with the ease of maintenance. That's really were MVC shines. You can extend it and not spend time programming around limitations and glass walls.

George Stocker
+1  A: 

If you are a WebForms guy it probably won't make your life easier. I am not saying that to be snobby either. There is nothing wrong with WebForms.

MVC allows a lot more control over your code, and for guys like me, coming from the Java world, into ASP.NET, it is a natural progression.

Remember MVC, is not a replacement for WebForms. It is just another way to do things.

A good analogy is WebForms = Automatic Transmission, and MVC = Standard Transmission.

Hope this helps.

Chrisb
+1  A: 

For me, ASP.NET web forms are a "leaky abstraction" to use a term from Joel S.

For example, I needed to put a RadioButtonList into a table, where one column was the button name, and the other was some descriptive text. However, you can't split a RadioButtonList's elements into a table, and the RadioButton class doesn't have a value attribute. So I had to code my own RadioButton with a value element.

In MVC, you're a lot closer to the HTML, so something like this is not a problem. I really liked what I saw of MVC, and I wish I could have used it on my current project (it was still in Beta when we started, and I didn't want the risk of significant code changes).

My $0.02.

ristonj