"Go" MVC mode for Android projects

Source: Internet
Author: User

MVC (Model-view-controller): M refers to the logical model, v refers to the view model, and C is the controller. A logical model M can be used for a variety of view model V, such as a batch of statistical data you can be represented by histogram, Pie v. A view model V can also be used for multiple logical model M. The purpose of using MVC is to separate the implementation code for M and v so that the same program can use different representations, whereas C exists to ensure the synchronization of M and V, and once m changes, V should be updated synchronously, which is exactly the same as the Observer pattern in design mode.

MVC Benefits: MVC separates the logic layer of the application from the interface, and the biggest benefit is that the interface designer can directly participate in the interface development, the programmer can focus on the logic layer. Rather than as before, designers put all the material in the hands of developers, who implement the interface. In the Eclipes tool, the development of Android in a more simple way, designers in the Anroiddraw design interface, in XML storage, in the Eclipes directly open to see the designer interface. The logical processing code is placed under the SRC folder. Let programmers focus more on the business.

The interface part of Android also uses the currently popular MVC framework, in Android:

1) View layer: The general use of XML file interface description, when used can be very convenient to introduce.

It also facilitates the modification of the later interface. The ID of the interface corresponding to the logic does not change, the code is not modified, greatly enhancing the maintainability of the code.

2) control layer (Controller): The task of Android control layer usually falls on the shoulders of many acitvity, this phrase also implies do not write code in acitivity, to through activity delivery model business Logic layer processing, Another reason for this is that the response time of Acitivity in Android is 5s, and if time-consuming operations are put here, the program is easily recycled.

3) Model: the operation of the database, the operation of the network, etc. should be processed in the model, of course, business calculations and other operations must be placed in the layer. is the binary data in the application.

---------------------------------------------------------

Original link: http://www.embedu.org/Column/Column531.htm
  Zhong Ai, huaqing Vision Embedded College Lecturer, reproduced please link form note!

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.