In-depth discussion of mvc mvp mvvm and mvcmvvm

Source: Internet
Author: User

In-depth discussion of mvc mvp mvvm and mvcmvvm

After reading "Android advanced light" and "Android source code design mode", I have a deeper understanding of mvc mvp mvvm. Next, I will explain the characteristics of the three in Android in vernacular, if there are any mistakes, I hope you will criticize and correct them.

1. MVCOrganize code by separating business logic, data, and interface display.

Model: The data that corresponds to the data part and accesses the data (including the data obtained from the database and the network)

View: displays the corresponding interface and responds to User Interaction Events (View depends on Model)

Controller: process the logic of user interaction events. It is generally responsible for reading data from the view and then sending data to the model.

Disadvantage: coupling of Model and View

View corresponds to a layout file, which does very little.

Activity is like a View and a Controller. It not only processes Data Binding operations in the layout file but also the Event Logic.

2.MVP

Model: The data that corresponds to the data part and accesses the data (including the data obtained from the database and the network)

View: it corresponds to Activity and is responsible for drawing and interacting with users.

Presenter: completes the interaction between views and models and processes business logic. (There is a Presenter in the View, and the Presenter interacts with the View through the interface)

Advantage: reduced Activity responsibilities and simplified Activity code. view and model layers are no longer completely decoupled from each other, and complicated logic code is extracted to the Presenter for processing.

The following figure compares MVC and MVP:

3.MVVM

It does not seem to be much different from MVP, except that the presenter layer is changed to the viewmodel layer, and the view layer and viewmodel layer are mutually bound, this means that when you update the data in the viewmodel layer, the view layer changes the ui accordingly..

Related Article

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.