Tuesday, September 7, 2010

Presentation Patterns: MVC vs. MVP (once again)

Presentation Patterns are one of my classical examples how unsophisticated we still are in our industry. MVC, MVP, PresentationModel, M-V-VM... everybody is supposedly using them but everybody has another concept how those patterns are realized.

Front_thumb_3.jpg This is like the different revolutionary groups in Life of Brian: Judean People's Front, People's Front of Judea, Popular Front of Judea ... they all look the same, they all have the same purpose, sometimes they are even the same people ... but the difference is still more important than everything else!

I blogged about this before: The same but different and Sophisticated Vocabulary: MVC

Today in the .Net web world there is basically ASP.NET Webforms and ASP.NET MVC.

ASP.NET MVC is a clean and opinionated implementation of the MVC pattern.

ASP.NET Webforms does not really imply a presentation pattern. Some people are claiming to do MVC with it, but basically Webforms leave you unguided (if not impeded) with realizing your separation of concerns.

However there is the Web Forms MVP project that presents a Webforms based framework realizing the MVP pattern.

Now we are back to the question what is the difference between MVC and MVP?

In Hansleminutes #202 Tatham Oddie, one of the creators of Web Forms MVP gives a simple explanation for web scenarios:

In MVC the request is handled first by the controller, which then consults/delegates to the model and the view.
In TekPub's ASP.NET 4 series this is called Controller First Execution:

In MVP the request is first going through the view, which signals events/actions that are handled by the presenter. The presenter then consults/delegates to the model:

Back when I was programming Java, I had numerous disputes whether JSF is MVC or not. Now when we look at the above definition, JSF is clearly MVP.
It is often claimed that JSF is MVC, because it is based on Servlets, which were initially a technical realization of MVC (that would mean that any relevant Java based web framework would be MVC).
But in my opinion JSF is clearly not MVC, because in the JSF programming model there is no controller artifact exposed.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...