MV(X) - makstron/info GitHub Wiki
The aim of these architectures is to separate the responsibilities of visualizing, processing, and data management for UI applications.
Their goals are to increase.
- Modularity
- Flexibility
- Testability
- Maintainability
TimeLine
MVC -> MVP -> MVVM -> MV?
- Model — is responsible for the business logic of the application. It manages the state of the application. This also includes reading and writing data, persisting application state, and it may even include tasks related to data management such as networking and data validation.
- View — this component has two important tasks: presenting data to the user and handling user interaction.
- Controller — the view layer and the model layer are glued together by one or more controllers.
- Input is directed to the Controller
- The View doesn`t have any knowledge of the Controller
- The View is aware of the Model it is expecting to pass on to it
MVP is a derivative of the MVC design pattern which focuses on improving presentation logic.\
- Model — The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.
- View — The View is used for making interactions with users like XML, Activity, fragments. It has got nothing to do with the logic that is to be implemented in the process.
- Presenter — The presenter gets the input from the View, processes the data with the help of the Model, and passes the results back to the View after the processing is done.
- Input is directed to the View
- The View holds the reference to its Presenter and the Presenter is aware of its View
- The View is not aware of the Model. The Presenter updates the Model
This pattern based on MVC and MVP which attempts to more clearly separate the development of UI from that of the business logic and behavior in an application.
- Model — the Model used in MVVM is similar to the model used in MVC, consisting of the basic data required to run the software.
- View — the View is a graphical interface between the user and the design pattern, similar to the one in MVC. It displays the output of the data processed.
- View-Model — the View-Model is on one side an abstraction of the View and, on the other, provides a wrapper of the Model data to be linked. That is, it comprises a Model that is converted to a View, and it also contains commands that the View can use to influence the Model.
- Input is directed to the View
- The ViewModel doesn`t have any knowledge of its View
- The View is not aware of the Model. The ViewModel updates the View
MVC | MVP | MVVM |
---|---|---|
* Input is directed to the Controller * The View doesn`t have any knowledge of the Controller * The View is aware of the Model it is expecting to pass on to it |
* Input is directed to the View * The View holds the reference to its Presenter and the Presenter is aware of its View * The View is not aware of the Model. The Presenter updates the Model |
* Input is directed to the View * The ViewModel doesn`t have any knowledge of its View * The View is not aware of the Model. The ViewModel updates the View |
-- | MVC | MVP | MVVM |
---|---|---|---|
Performance Evaluation | * Data binding in MVVM creates an additional overload that could drastically affect its performance when performing complex tasks. | ||
Compatibility | * the best of the lot due to its data-binding | ||
Modifiability | * |