

If you look at those graphs I think you will see that the important points of MVC (of which MVP is a derivative) exist in all of them (see the arrows). That is -- the Model is in a separate layer and generally independent from the Presentation layer code. As I said above, the differences are mostly about how to divide up responsibilities and dependencies in the Presentation layer. Many of the differences, such as between Supervising Controller and Passive View are differences in the thinking of guys like Martin Fowler over the years (he retired MVP but it still lingers in .NET). All of those ideas can be used by programmers for their implementations.
People can (and do) talk until they are blue in the face about which is their favorite, but it is the basic concepts and possible options that are what we programmers really need to know. The range of patterns from Transaction Script all the way up to MVC are all solutions to problems and useful depending on needs and circumstances.
There are a range of implementation possibilities in MVC. TomB showed the most basic example of Push based Controller code here:

Originally Posted by
TomB
PHP Code:
$user = $this->user->find($id);
$this->view->assign('firstname', $user->firstname);
$this->view->assign('surname', $user->surname);
$this->view->assign('address1', $user->address1);
But other variations are possible, such as passing the Model object to the View:
PHP Code:
$user = $this->user->find($id);
$this->view->assign('user', $user);
Or passing an array of the pertinent Model data to the View:
PHP Code:
$user = $this->user->find($id);
$this->view->assign('userdata', $user->getData());
And in a Pull based system all this code would be in the View, which would load the Model directly:
PHP Code:
$user = $this->user->find($id);
$this->template->assign('firstname', $user->firstname);
$this->template->assign('surname', $user->surname);
$this->template->assign('address1', $user->address1);
There are pros and cons to all of these approaches. These patterns and this information are all tools to allow us to make implementation choices. Having an understanding of the options and possibilities allows us to make informed decisions.
However, there is also a lot of personal preference in these discussions -- which is why these threads get so long.
Bookmarks