views:

585

answers:

4

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 ?

+6  A: 

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.

Cameron MacFarland
In either case, you're involved with models, and that's got to be a good thing.
Noon Silk
+6  A: 
free-dom
I'm not sure those dependency arrows are right. In MVC, why does the View have a dependency on the Model?
Cameron MacFarland
It certainly doesn't *have* to be, however this is the more common implementation. For example, if you use ASP.NET MVC the best practice is to make your "view" dependent on a type (creating a strongly typed view). Typical MVC implementations send a model to a view, then let the view decide what to do with it (thereby creating a dependency), whereas in MVP the View will literally ask the presenter "What data should I put in this textbox."
free-dom
A: 

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: http://www.object-arts.com/papers/TwistingTheTriad.PDF

IBM's Taligent system also used MVP - they describe what and why here: http://www.wildcrest.com/Potel/Portfolio/mvp.pdf

cartoonfox
+1  A: 

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

Anton Setiawan