Mvc:
Coupling is high, and view model controllers can access each other.
Model View Controller.
In Android
- View corresponds to the layout XML file;
- Model corresponds to data files or data bodies obtained by the network;
- Controller corresponds to activity.
Get the data (model) in the activity (Controller) and show the data on the view.
Activity separates the view from the model and binds and completes the logic in the activity.
Mvp:
M and V must be accessed directly through P, and M and V cannot interact directly.
Model (data layer): Data acquisition for data acquisition (database operation, network request operation)
View (UI layer): Activity,fragment or view, contains the presenter member variable, implements the abstract interface of P, the business logic on the view is implemented on p, and P invokes the logic of view to display the result on the view.
Presenter (business logic Layer): Used to decouple model and view.
MVP effectively reduce the complexity of the view, avoid a lot of business logic on the view, to remove the view and model of the coupling, extensible, can test, ensure the system neat and flexible. The view layer is not allowed to interact directly with the model layer and must pass through the P layer to relay. This means that the logical control of the data and view is placed on the P-layer.
Goal: A set of logic for different UI.
The MVP is embodied in Android:
MVC Architecture and MVP architecture