What is Model View Presenter? [closed]

Can someone please explain in a way as simple as possible what the Model View Presenter pattern is? What is the difference with Model View Controller ? Which is best or for which purpose ?


Model View Presenter and Model View Controller both try to solve the same "seperation of concerns" problem.

The primary difference you'll find is that Model View Controller (MVC) is often implemented with some coupling between the view and some model of some sort - thereby a given view is specifically purposed to provide a visualization of a given object (model).

In the Model View Presenter pattern you generally find that the Presenter takes care of working with the model, and deciding what information from it will be needed to form some sort of visualization.

In this diagram, arrows represent dependencies:

MVC and MVP dependencies

Typically you hear this pattern discussion come up when discussing the ASP.NET MVC framework, and come across information regarding the MVP pattern and it's implementation in ASP.NET WebForms. It is common in my experience that it is believed that WebForms is in and of itself an MVP patterned framework - this is not true. WebForms does however make it very easy to implement an MVP pattern - your best resource for this would be to investigate the Web Client Software Factory from the Patterns and Practices team.


Martin Fowler has a page on UI design patterns, in which he defines and then talks about MVC, MVP and other patterns.

http://martinfowler.com/eaaDev/uiArchs.html

To summarise the differences, Controllers in the MVC have more control over the UI, and handle events, while a presenter in the MVP is more passive, and just presents information through the UI.

In general there's not much difference, and often the line between them is blurry.


Fowler separates MVP into 2 patterns: Supervising Presenter and Passive View.
Aviad Ezra has a good article on this topic http://aviadezra.blogspot.com/2008/10/model-view-presenter-design-pattern.html.
I think MVP is better for desktop, and MVC is for web app, because in desktop, Model has the capability to raise the event


Dolphin Smalltalk used to have an MVC implementation but then they migrated to MVP.

Here's the technical paper that outlines what they did and why.

IBM's Taligent system also used MVP - they describe what and why here.