What is Model View Presenter?

bluediapente picture bluediapente · Aug 23, 2009 · Viewed 34.6k times · Source

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 ?

Answer

apiguy picture apiguy · Aug 23, 2009

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:

CodePlex site: http://www.codeplex.com/websf

A great screencast covering the topic: http://www.pnpguidance.net/Screencast/MVPBundleScreencastWCSFModelViewPresenterDesignPattern.aspx