Jeffrey Palermo (.com)

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Martin Fowler evolves his Model-View-Presenter pattern - level 300

I subscribe to Martin's MVP pattern.  If you are new to it, please have a read.  It's a variation of Model-view-controller that puts more behavior in the controller and less in the view.  I have tended to vary the amount of logic that belongs in the view depending on the scenario.  Martin has split the pattern into two:  one part leans toward balancing the logic and putting UI-specific behavior in the view and application behavior in the controller.  Read it here.  The other seeks to make the view as thin as possible and renders the view very passive.  In this case, the controller has every bit of behavior, including setting every single field.  Read it here.

I'm glad he made the split because it really is two different ways to do it.  I tend to throw a domain object at the view and say "here, show this", whereas PassiveView would say to set each field individually and not to let the view know about the domain object.  In Supervising controller (which I favor), the view can know about the domain object and how to bind it to it's GUI elements.

As with all patterns, they have advantages and drawbacks.  The worst thing we can do is be dogmatic about one and declare its applicability to all scenarios.  I've used Supervising Controller in ASP.NET and WinForms, and I like the way it separates behavior from visual goo.  I also like how it pulls behavior into a class that's easily tested.


Posted 08-29-2006 3:46 PM by Jeffrey Palermo
Filed under:

[Advertisement]

Comments

Vikas Kerni wrote re: Martin Fowler evolves his Model-View-Presenter pattern - level 300
on 08-29-2006 10:43 PM
Hi Jeff First I came to Know MVP from your architecture post and wrote the following post http://vikasnetdev.blogspot.com/2006/07/soa-friendly-architecture-version-of.html http://vikasnetdev.blogspot.com/2006/07/soa-friendly-architecture-version-of_25.html Feel free to criticize it. :) Recently we had discussion on asp.net why MVC is so confusing. http://vikasnetdev.blogspot.com/2006/08/is-3-layered-architecture-mvc.html
Jason Haley wrote Interesting Finds: August 29, 2006
on 08-29-2006 10:46 PM
Marco wrote re: Martin Fowler evolves his Model-View-Presenter pattern - level 300
on 08-30-2006 1:32 PM
Can you give a (or spend a blog post on it) small sample about how you use the Supervisoing COntroler in asp.net? Thanks Marco
Dim Blog As New ThoughtStream(me) wrote Journey Into Agile: Model View Presenter
on 01-22-2007 9:46 AM

I spent some time this weekend, doing some R&D on the Model View Presenter pattern, to get myself...