Please enable JavaScript.
Coggle requires JavaScript to display documents.
MVC/MVP/ MVVM/ MVI, Presenter, ViewModel: View relationship can be 1:1 or…
MVC/MVP/ MVVM/ MVI
-
MVI
-
It works based on the principle of unidirectional data flow. The data circulates between Model and View only in one direction
-
-
-
-
MVVM
ViewModel
Model
- Data Management: fetching, storing, and managing the app's data. interacts with data sources such as DB, APIs, or local storage to retrieve or persist data.
- Business Logic: business logic that processes and manipulates the data such as performs calculations, validations, transformations, and other operations ensure the integrity and consistency of the data.
- Data Notifications: The Model notifies the ViewModel about changes in the data. This can be achieved through various mechanisms such as events, callbacks, or reactive streams. That enables the ViewModel to update the View accordingly.
- Data Source Abstraction: provides a clean interface for the ViewModel to interact with the data, keep the details of how the data is fetched or stored transparent from the ViewModel.
- Business Rules Enforcement: ensures that the data adheres to the specified rules and performs validations or checks before modifying the data.
- State Management: manages the state of the app, keeps track of the current state, such as loading, success, error, or empty, and communicates it to the ViewModel, which in turn updates the View accordingly.
- Data Binding and Exposing Data: exposes the necessary data and state from the Model to the View. Also ensures that the View is notified of any changes in the data, allowing for automatic data binding and UI updates.
- View Interaction and Event Handling: handles user interactions and events from the View, and performs the necessary actions or updates the data accordingly, may also trigger navigation or display messages to the user.
- Business Logic and Data Manipulation: contains the presentation-specific business logic, performs operations on the data received from the Model, such as filtering, sorting, or aggregating.
- State Management and View State: manages the state of the View, keeps track of the current state, such as loading, error, or success, and updates the View accordingly, and handles transitions between different states and provides feedback to the user based on the current state.
- Communication with the Model: interacts with the Model to fetch or modify data, may also trigger data updates in response to user actions or events.
- Testing and Separation of Concerns: encapsulates the presentation logic, allowing for unit testing without direct dependencies on the UI. By separating the concerns of the View and the Model, it facilitates the testability, maintainability, and reusability of the code.
-
-
Presenter
-
- Should contain only business logic
- Shouldn't contain any specific Platform Apis
-
-
-
-
-
-
-