Software maintenance has always been a problem. Code organization and separation of responsibilities is not always an easy task.
Aiming to solve these kind of problems, it was developed architectural standards that simplify this issue and resolve the issue of separation of responsibilities and organization, separating what is model, what is vision and what is the mediator and how they work. The main ones are:
MVC is an architectural pattern that is based on the following concepts:
- View: The user interaction layer. It just makes the display of data. Only changed by the Model.
- Model: The data manipulation layer (reading and writing data) and also its validations (application logic core layer).
- Controller: The responsible for receiving all user requests, controlling which Model to use and which View will be shown to the user.
In MVC, every action in the View correlates with a call to a Controller along with an action. In the web each action involves a call to a URL on the other side of which there is a Controller who responds. Once that Controller has completed its processing, it will return the correct View.
Examples of MVC Frameworks: Spring MVC, JSF¹, ASP.NET MVC, Struts 2, Play Framework.
¹ – There’s a lot of people that consider JSF a MVP framework.
MVVM is an architectural pattern that is based on the following concepts:
- View: The user interaction layer. It makes the display of data. Usually only altered by the ViewModel, by databinding.
- Model: The application logic core layer.
- ViewModel: The responsible for mediating communication between Model and View. In ViewModel, there is a kind of linker (binder) that synchronizes the ViewModel with the View. For example, in KnockoutJS, when using databinding: when the user enters something in a field, for example, that word is being mapped into a variable set by the databinding in real time, for each letter typed.
Examples of MVVM Frameworks: KnockoutJS, Meteor, Prism, MVVM Light, Caliburn Micro.
MVP is an architectural pattern that is based on the following concepts:
- View: The user interaction layer. It makes the display of data, but may have some UI manipulation logic (such as mouseDown, keyDown, etc.).
- Model: The layer that defines the data to be displayed or changed by the user. Any logical manipulation and access of these data.
- Presenter: It acts on the Model and the View. When the data are altered in Model it reloads the View and when the view is altered synchronizes Model. Very common in event-oriented architectures.
Examples of MVP Frameworks: Windows Forms, ASP.NET Web Forms, JavaFX, Swing, Vaadin.
MVW is not an architectural pattern, but worth mentioning because its main concept is to support more of an architectural pattern, ie, the same framework can be used as MVC or as a MVVM, for example. The W (Whatever) stands for “whatever works for you”
Examples of MVW Frameworks: AngularJS, Tipsy.