views:

967

answers:

9

In addition to being a 30 year pattern, MVC was never meant for current applications. MVP was its successor and designed to handle event based apps coming out in the 90s. Passive View and Supervising Controller seem to have risen to the top. For those two, it almost isn't necessary to talk about MVC/MVP.

Specifically, is the controller action in ASP.NET MVC that brings back a view creating that view? In MVC, the controller doesn't create views or talk back to them. How accurate is it to call ASP.NET MVC an MVC implementation? Or, what would be an accurate name for it?

+13  A: 

I think it's Ruby on Rails that inspired MS to create asp.net MVC.

Morph
I agree with that
marcgg
Well it certainly allows them to compete in that sphere, though I think it was because webforms are broken by design :P
annakata
+8  A: 

Close enough, and it's a sales strategy.

They sell ASP.NET against other technologies that identify themselves as MVC. So it's competitively useful to name it to be perceived in the same category.

Microsoft wins more often by product positioning than by accurate technology identification. (Plus long-term delivery, IMHO.)

le dorfier
+1  A: 

Best guess, everyone's heard of MVC. MVC has been beaten in as a "best practice" for quite awhile, and thus a whole generation (or two, or three) of developers see MVC and think happy thoughts.

Also, plenty of other frameworks espouse MVC in a similiar light so Microsoft probably feels compelled to do likewise.

In short, I doubt very much that there's a strong technical reason for it.

Kevin Montrose
A: 

I think this was more of a "panic marketing decision" then a technical decision. RoR was stealing markets every second and MSFT completely panicked, so MSFT felt they had to deliver something which gave them the opportunity to get some of the hype back to "their camp" again...

Also they needed to help their developers gain bac teir self-respect again by getting to associate this hyped word with themselves so that the .Net Developers could look themselves in the mirror again without feeling ashamed for that they didn't know MVC since their platform of choice didn't deliver this kind of pattern for them (out of the box)

For a medium skilled (.Net) developer it's really difficult to not feel like a dinosaur when a medium skilled RoR developer fires up rake and creates a spike in less then 15 minutes having a working and running proof of concept before the .Net developer even is finished starting vstudio.exe... ;)

I guess it's a controversial standpoint, but it's mine and I'll defend it till the bitter end ... ;)

There are countless examples today of that yes, MVC and scaffolding will give you an initial speed boost, yes. But for maintainability, code reuse, encapsulation and mostly every really important thing - MVC just isn't the "silver bullet" and most of the times WebForms are far superior in the long run (unless used like toilet paper of course)

Thomas Hansen
Disagree on the panic marketing statement. This was an insider-driven project by Phil Haack and Scott Guthrie. In no way did the marketing team get a hold of this. This was full on developer-driven.
p.campbell
I also don't agree with the above statement. I have implemented Web Forms in environment where concepts like view state alone has caused endless problems. I fail to see where Web Forms are easier to maintain as well. MVC is not a silver bullet by any means but most definitly a good alternative in some situations.
Diago
Do you really think that RoR made MS "panic"? You need to get out more.
Chris Lively
To the three comments above, can you explain exactly how ASP.NET is an MVC? I'm comparing to the original SmallTalk-80 implementation, since everything else is just mutations.
4thSpace
I doubt Microsoft would ever deliver something as large-scale as ASP.NET MVC on a panic in response to something like RoR. MVC is something people asked for, and its a successful web development methodology. Its just Microsoft responding to customer demand with a successful development platform.
jrista
@4thSpace: The classic SmallTalk-80 implementation was for text-based screens back before the internet. Despite the fact that we present views as rich markup and javascript, the concept is still the same. Whether its text on a screen or pretty web pages, its still a view. Whether your responding to low-level keyboard commands, or high-level actions, they are still handled by a centralized controller. A model is a model...MVC or not. ;) Just because the things between the View and Controller have changed (actions via Url vs. keyboard keypress), the actual concepts themselves are still the same.
jrista
+4  A: 

ScottGu eludes to the answer in the first part of his post on the first MVC demonstration here. The short answer is that people asked for it and Microsoft decided to go with it. It fits with the current .Net model for adding as many options as possible, allowing the framework to reach a bigger target market, and also provide developers with the right tools for the right project.

Diago
+1  A: 

You can roll your own MVC with the current ASP.NET framework and still keep the postback model.

http://www.codeproject.com/KB/aspnet/RollingYourOwnMVCwithASP.aspx

I think one of the reasons they implemented MVC was to move away from the postback model.
rojoca
The postback model has it's drawbacks - such as HTML bloat and all that viewstate that is created by default. The biggest advantage of the MVC design pattern is that there is no-more code-behind file and thus it facilitates automated unit testing using such tools as MBUNit. The article I wrote was an example of keeping the postback model but also implementing a design that also allows for complete automated unit testing.
+2  A: 

MVC as implemented by ASP.NET MVC isn't the MVC pattern of old. In what I'll call "classic" MVC the View has direct, but read only, access to the Model, in ASP.NET MVC it's considered bad form to access your business model directly from the View. What you end up with is something very much like Supervising Controller + Passive View:

public class MvcExampleController : Controller
{
    public ActionResult ActionMethod(BoundInputData inputData)
    {
        var results   = DoActualWorkInTheModelWith(inputData);
        var viewModel = CreateViewModelFromThe(results);

        return View(viewModel);
    }
}

To me this looks more like a Supervising Controller than classic MVC. Once the work gets done in the Model, the view gets passed a ViewModel (aka PresentationModel). The ViewModel generally has a 1 to 1 relationship with the UI elements in the view and may or may not look anything like the objects in the actual Model. A View that acts on a ViewModel and not the actual Model smells alot like a Passive View to me.

I won't get into whether or not this is a "real" MVC implementation or not, but if your argument is that ASP.NET MVC doesn't use modern web design patterns I have to disagree.

Anthony Conyers
+10  A: 

ASP.NET MVC is simply Microsoft's acknowledgement of the success of MVC implementation within web frameworks like Ruby on Rails and Django. The realization that many web developers would like a more hands on approach to web development which embraces the "opinionated" programming model (convention over configuration) and strays away from the stateful abstraction that ASP.NET WebForms provides.

Is it an exact implementation of the Smalltalk MVC pattern? No. Is it a result of panic? No. Is it a result of the success of both Ruby on Rails and Django? Yes.

I happen to love this model as it embraces the rich framework provided by .NET and the ASP.NET stack while remaining minimalistic in approach and use of convention based development.

Adam Carr
A: 

Hi

This is a great question, a lot of people have asked this question in the early days of MVC. Here is the answer from Phil Haack one of the lead developers on the project!

http://haacked.com/archive/0001/01/01/everything-you-wanted-to-know-about-mvc-and-mvp-but.aspx

Check it out, read the links and go from there.

Also, an answer to the debate maybe S#arp Architecture. They have built a layer on top of MVC to make it act more like MVP. Check them out if you're looking for soemthing along those lines.

Good luck!

5x1llz
Thanks but his conclusion is very wrong - "This framework (i.e., ASP.NET MVC) employs the MVC pattern rather than the MVP pattern because it does not attempt to emulate rich client development, and thus the MVC pattern is more appropriate." Modern web apps, just like modern client apps, use MVP. This occurs in web apps because the web browser handles user input. You'll be hard pressed to find an app that uses MVC, meaning the controller handles user input directly.
4thSpace