Archive for the ‘TDD’ Category

Very good articles on MVC, MVP and more.

Saturday, May 31st, 2008

Very good articles on MVC, MVP and more.

Interactive Application Architecture Patterns

An Introduction to the Model-View-Controller, Model-View-Presenter, and Presentation-Abstraction-Control Patterns

Presenter First approach in MVP

Wednesday, May 28th, 2008

A colleague of mine recommended me a great paper to read:

 "Presenter First: Organizing Complex GUI Applications for Test-Driven Development", agile, pp. 276-288, AGILE 2006 (AGILE’06), 2006.

I really like the idea in this paper, it’s practical and useful in daily development life.

There are many articles or implementations and even courses talk about MVC or MVP, but most of them only gave very simple examples for them. Yes, it’s really easy to understand or sounds clear for a simple M-V-C piece or simple M-V-P piece, however in real life, a complete application contains many Models, Views, and Controllers/Presenters, this will be much harder than a simple sample.

This paper give a great approach in MVP best practice, I am still learning more and will do some experiment  development, but I already feel I should strongly recommend this paper.

More valuable links and examples, videos here:

http://www.atomicobject.com/pages/Presenter+First

MVC vs MVP again…

Monday, May 26th, 2008

Todd have a great new blog post about MVC vs MVP. :

 Model View Controller (MVC) Pattern

The MVC pattern is a UI presentation pattern that focuses on separating the UI (View) from its business layer (Model). The pattern separates responsibilities across three components: the view is responsible for rending UI elements, the controller is responsible for responding to UI actions, and the model is responsible for business behaviors and state management. In most implementation all three components can directly interact with each other and in some implementations the controller is responsible for determining which view to display (Front Controller Pattern),

Model View Presenter (MVP) Pattern

 

The MVP pattern is a UI presentation pattern based on the concepts of the MVC pattern. The pattern separates responsibilities across four components: the view is responsible for rending UI elements, the view interface is used to loosely couple the presenter from its view, the presenter is responsible for interacting between the view/model, and the model is responsible for business behaviors and state management. In some implementations the presenter interacts with a service (controller) layer to retrieve/persist the model. The view interface and service layer are commonly used to make writing unit tests for the presenter and the model easier.

Key Differences

So what really are the differences between the MVC and MVP pattern. Actually there are not a whole lot of differences between them. Both patterns focus on separating responsibility across multi components and promote loosely coupling the UI (View) from the business layer (Model).  The major differences are how the pattern is implemented and in some advanced scenarios you need both presenters and controllers.

 

Here are the key differences between the patterns:

 

·         MVP Pattern

o    View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.

o    Easier to unit test because interaction with the view is through an interface

o    Usually view to presenter map one to one. Complex views may have multi presenters.

 

·         MVC Pattern

o    Controller are based on behaviors and can be shared across views

o    Can be responsible for determining which view to display (Front Controller Pattern)

I previously wrote some notes on this topic.

Some other useful links:

http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf