Learning the Model View Presenter Pattern

The guys over at Patterns and Practices got it right. They've put together a package (available via a CodePlex project here) on learning and understanding the Model View Presenter Pattern (MVP). It's kind of a "mini-guidance" package and not the big behemoth you normally see from these guys that:

  • Provides guidance on how MVP to promotes testability and separation of concerns within the UI
  • Illustrates how to implement MVP with standard ASP.NET
  • Illustrates how to implement MVP with ASP.NET and the Composite Web Application Block

The package contains full documentation on the pattern, unit tests, and source code (for both WinForms and CAB) demonstrating it. Very nice and very easy to digest! Check it out here if you're just getting started and want to see what MVP is about.

Published Thursday, December 06, 2007 9:35 PM by Bil Simser
Filed under: , ,

Comments

Friday, December 07, 2007 8:41 AM by David Fauber

# re: Learning the Model View Presenter Pattern

I don't really like what they did there.  Having views like IContactDetailView puts the model into the view which is exactly what you are trying to separate.  IMO Views should be things like Grid, Spreadsheet, Detail, etc which can handle any domain object (Contact, Customer, etc)

Friday, December 07, 2007 10:50 AM by Troy

# re: Learning the Model View Presenter Pattern

A view is a visualization of a specific set of information, not a general thing like a grid, etc. The P&P team did a great job, and implemented MVP in a way that is entirely consistent with the way hundred of thousands of developers worldwide understand MVP. Sorry if you don't agree.

Friday, December 07, 2007 3:07 PM by David Fauber

# re: Learning the Model View Presenter Pattern

"undred of thousands of developers worldwide understand MVP"

I wasn't buying what you were saying at all until you implied that you are speaking canonical wisdom on behalf of hundreds of thousands of devs worldwide.  

Friday, December 07, 2007 3:12 PM by David Fauber

# re: Learning the Model View Presenter Pattern

"The P&P team did a great job, and implemented MVP in a way that is entirely consistent with the way hundred of thousands of developers worldwide understand MVP. Sorry if you don't agree."

The entire pattern is about separating model from view, not mashing them together.  I'd suggest checking out P of EAA (Fowler).  In your approach you're going to end up with a number of view classes which are equal to the number of views you really need, multiplied by the number of domain objects which need to use them.  In short, a lot of replicated code.

Saturday, December 08, 2007 5:32 PM by David Fauber

# re: Learning the Model View Presenter Pattern

This is an example of wht the guy writing the MVC framework for MSFT is using for views:

weblogs.asp.net/.../asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx

List, Detail are the examples he gives and consistent with what I would choose.  Maybe I'm just confusing MVC and MVP, but I thought the "V" parts were pretty similar between the two.

Saturday, December 08, 2007 5:37 PM by David Fauber

# re: Learning the Model View Presenter Pattern

This is an example of wht the guy writing the MVC framework for MSFT is using for views:

weblogs.asp.net/.../asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx

List, Detail are the examples he gives and consistent with what I would choose.  Maybe I'm just confusing MVC and MVP, but I thought the "V" parts were pretty similar between the two.