MVC vs MVP – Part 2


#What is the major difference ?

In MVC, the biggest portion of code is shared between the Controller and the View. The controller contains the logic, and the View know how to render the model and listen model changes.

In MVP, the biggest portion of code is solely in the Presenter and the View is entirely passive. The presenter contains the whole logic, and the View doesn’t know what it’s displaying.

#What is the benefit of each approach ?



#When to use MVC or MVP ?

This is a project specific question: sometime the framework used is designed for on approach, sometime you will use the other approach because you cannot rely on the View for your tests, etc…

Between MVC and MVP, the best approach is the approach that match your needs.

#An example of programme designed with both approach:

mvp example
mvc example

For MVC or MVP, the order of instantiation of the view, controller/presenter isn’t important. Try to focus on the communication between the 3 entities (model, view, controller/presenter).

comments powered by Disqus