Model-View-Presenter split into two "new" patterns

For the past year or so, Martin Fowler has included the pattern Model-View-Presenter, or MVP, in his upcoming addendum to  Patterns of Enterprise Application Development.  Due to apparent confusions between MVC and MVP, Fowler has now split this pattern into what he's calling “Passive View” (http://martinfowler.com/eaaDev/PassiveScreen.html) and “Supervising Controller/Presenter” (http://martinfowler.com/eaaDev/SupervisingPresenter.html).  (Now what am I to do! ;)

Passive View stresses zero/none/nada dependencies between the View and the Model.  Previously, with MVP, the View could be given a dependency to the Model to decrease the amount of communications between the View and the Presenter.  But, from how I understand it, the Controller in Passive View (previously the Presenter in MVP) would now have a dependency on System.Web, in ASP.NET anyway, to facilitate direct communications with the View display elements.  A “Test Double“ could then sit in for the View for unit testing purposes.  Although I really don't like the idea of a controller depending on System.Web, Passive View seems a bit simpler than MVP.  But instead of it depending on System.Web, Fowler suggests the use of a “Gateway“ to avoid the dependency.  The primary disadvantage to Passive View, in ASP.NET, is that it would become much more tedius to bind to a webcontrol, such as the datagrid, if the View has no knowledge of the Model.  I suppose DTOs could be used in their stead.

Alternatively, Supervising Controller looks to be a “flexible” interpretation of the original MVP pattern.  I.e. the View isn't completely dumb and knows how to use a limited amount of the Model.  Supervising Controller leaves the data binding up to the View and only helps out when the logic becomes non-trivial.  I believe this is very similar to how I discussed MVP to be in http://www.codeproject.com/useritems/ModelViewPresenter.asp.  The primary benefit to this pattern is that it makes the presentation logic easy to unit test.  The primary drawback, in my opinion, is that it makes it difficult to draw a clear line between what should go in the View (the code-behind in ASP.NET) and what should go in the Supervising Controller.  Passive View makes the separation of responsibility a bit more clear.

Now off to go update my class PPTs.

Billy

This article is part of the GWB Archives. Original Author: Billy McCafferty

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.