Differences between MVC, MVP and MVVP

Since I have been developing in Yii for my "entire life", I'm bound to MVC model. And since it suits me very good, I don't want to and don't plan to change it. Even though, it is nearly always good to know, what are the alternatives -- MVP and MVVP.

All three are architectural patters and all three have the same key elements:

  • model -- database table or view representation in code, business object, set of business rules, all defined as classes,
  • view –- user interface to interact with, usually a webpage or single view in web application,
  • controller (MVC), viewmodel (MVVP) or presenter -- application logic, methods separating view from model.

And now about differences:

Controller:

  • one-to-many relation between the controller and the views,
  • one controller will be responsible for initiating the display and controlling user interactions in many different views,
  • views should always use controllers to interact with models and never do this directly,
  • in general -- controller pick data from model and feeds it into view.

ViewModel:

  • one-to-one relation between the view model and the views,
  • views interact with the view model by binding to the view model’s properties and functions.

Presenter:

  • one-to-one relation between the presenter and the views,
  • there is no mechanism to bind the views to a view model,
  • each view implements an interface providing the means for the presenter to interact with the view,
  • each view has a reference to the presenter; this allows views to forward messages to the presenter.

This article is based on "The concise explanation" from "Joel in Point Form" blog. It's just a short check-list, very similar to above one. The same blog has much larger and explained in deep details another article on the very same topic. You are highly encouraged to read it, if above short-version does not suit you.

Leave a Reply