Difference between MVC, MVP and MVVM
Model View Controller (MVC) is an architectural pattern used in Software Engineering. Using this model, a software engineer can independently develop and test the domain logic and the user interface. The model basically manages the information and makes the observer aware of any changes made in the information. The Model View Presenter (MVP), on the other hand, helps in automated unit testing and is a derivative of the MVC. Model View ViewModel is a specialization of MVC and is used by a User Experience developer who is generally oriented towards business logic.
Definitions
In the case of MVC, view transforms a model into a form which is suitable for the user to interact with it. There can be more than one view for a single model for various purposes. A controller is a link between the user (the source of input) and the viewport or model (that performs action based in the input). MVP view displays data and directs commands to the presenter. Presenter is responsible for the changes made in the view in accordance with the commands received. The view in the case of MVVM is similar to that of the MVC. ViewModel can be regarded as the conceptual state of the data. It is an abstraction of the view and binds it with the model.
History
MVC was described by Trygve Reenskaug for the first time in 1979. He published a paper – “Applications Programming in Smalltalk 80 - How to use MVC” that gave an in-depth explanations. MVP was introduced in 1990 at Taligent which was a joint venture of HP, IBM and Apple. Microsoft began using MVP in their documentations in 2006. Martin Fowler analyzed many variants of MVP in his articles. John Gossman published the MVVM pattern on his blog in 2005. It was designed to support WPF and Silverlight.
Description
There are five steps in flow of control in the MVC pattern. These are related to user interaction, role of handler, notification to model by controller, view and model interaction and restarting the cycle. In the MVP pattern, when the user triggers a method of view a method of presenter with no parameter and no return value is invoked. Presenter acts upon model and updates the view accordingly. MVVM not only separates functional development as in case of MVC but also binds the data as far back as possible resulting in minimised need for code behind in the view.
Similarities and Differences
MVC
- Model View Controller (MVC) is an architectural pattern used in Software Engineering.
- MVC was described by Trygve Reenskaug for the first time in 1979.
- There are five steps in flow of control in the MVC pattern.
MVP
- Model View presenter (MVP) helps in automated unit testing and is a derivative of the MVC.
- MVP was introduced in 1990 at Taligent.
- When user triggers a method of view, a method of presenter with no parameter and no return value is invoked.
MVVM
- John Gossman published the MVVM pattern on his blog in 2005.
- It binds the data as far back as possible resulting in minimised need for code behind in the view.
- It is a specialization of MVC and is used by a User Experience developer who is generally oriented towards business logic.