MVC Architecture and MVP architecture

Source: Internet
Author: User
Mvc:

Coupling is high, and view model controllers can access each other.

Model View Controller.

In Android

  1. View corresponds to the layout XML file;
  2. Model corresponds to data files or data bodies obtained by the network;
  3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.