CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo [MVP]

Software management consultant and CTO, Headspring Systems

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.



Comments

Vikas Kerni said:

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
# August 29, 2006 10:43 PM

Jason Haley said:

# August 29, 2006 10:46 PM

Marco said:

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
# August 30, 2006 1:32 PM

Dim Blog As New ThoughtStream(me) said:

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

# January 22, 2007 9:46 AM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication