Analysis and Practice of Android source code design patterns (25)

Source: Internet
Author: User

Analysis and Practice of Android source code design patterns (25)
Chapter 2. Introduction and practice of MVC 1. Basic Introduction of MVC

MVC stands for Model-View-Controller. It is short for model-view-controller. MVC is a framework pattern rather than a design pattern. GOF regards MVC as a combination of the observer pattern, policy pattern, and combination pattern, while the core is the observer pattern. In short, the framework is wise and used to divide software design. The design mode is a small skill. It proposes solutions to specific problems to improve code reuse rate and reduce Coupling Degree.

1. Advantages of MVC

(1) first, it is easy to understand and have low technical content, which is easy to maintain and modify at a low cost for development and maintenance.

(2) The coupling is not high, and the performance Layer and the business layer are separated to perform their respective duties, which is very favorable for development.

2. disadvantages of MVC

(1) It is not easy to fully understand MVC. Using MVC requires careful planning. Because of its complicated internal principles, it takes some time to think about it. At the same time, due to the strict separation of models and views, it also brings some difficulties to debug the application. Each component must be thoroughly tested before use.

(2) for small projects, MVC will increase the workload and complexity.

2. Application of MVC in Android

In Android, MVC applications are classic. In Android, the View layer generally uses XML files to describe the interface. Example:


  

Most Model models correspond to local data files or data bodies obtained from the network. In many cases, the processing of such data will also be carried out at this layer.

The final Controller is the responsibility of the right Activity.

3. Summary

Although we feel the MVC structure of Android in the above introduction, this framework is not built by ourselves, but is built and provided to us by the framework, in normal development, especially Android development, we do not often use the MVC mode to build our own framework structure from the Android UI system.

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.