MVC MVP MVVM in Android

Source: Internet
Author: User

App architecture is a development scenario

The first is the understanding of the model layer:

My understanding: Themodel layer is a collection of properties and methods that get these properties.

For example, in Android, the data in the database is the model layer, ORM Framework is also the model layer, if the search operation, then the search conditions are not the model layer, and after the search data preprocessing is not the model layer.

In fact, these two are not part of

In Android:

The default development pattern is MVC, where the activity is the Controller,xml file and the custom control is view. The network class for the Web request operation is model, and the View property is updated directly inside the callback interface of the net request.

Then in order to solve the coupling between the VC, the above network callback interface is changed to not directly update the view, but to presenter to relay, the same, in the view click is the first to presenter to relay, such a development mode is MVP.

When M and V are fully decoupled, you can completely refactor the view layer without worrying about the model layer's need to change the test, or you can change the model layer implementation to another way, regardless of the view problem.

While MVVM is also an improvement to MVC, which is also about view and model decoupling, but the form is different, it needs to be noted that there is a ViewModel framework to support the interaction between view and ViewModel. And the function of the ViewModel layer is the business logic, when binding a view when the unbind, and then the business logic to the model layer to do.

Things to be aware of, sometimes business logic is difficult to distinguish, it is necessary to identify what is common according to the project, can be used as the model layer, which is only this page will be used to put into the business logic layer. This is related to the individual's overall control and project experience.

MVC MVP MVVM in Android

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.