Android and MVC Design Patterns

Source: Internet
Author: User

Write in front, before doing a period of time mobile development, and later because of the work reasons stranded, the latest to pick up the Android authoritative Programming Guide to learn, by doing a study note.

First of all, I would like to say that whether it is computer trained or training course origin, have heard the high cohesion low coupling and MVC two words. The MVC pattern is to solve the relationship between cohesion and coupling in the process of software engineering. (wiki view the definition of cohesion coupling)

The MVC pattern (model–view–controller) is a software architecture model in software engineering, which divides the software system into three basic parts: model, view and controller.

The MVC pattern was first proposed by Trygve Reenskaug in 1978 [1], the Xerox Palo Alto Research Center (Xerox PARC) in the 1980s for the programming language Smalltalk invented a software architecture. The purpose of the MVC pattern is to implement a dynamic program design that simplifies the subsequent modification and expansion of the program, and makes it possible to reuse a part of the program. In addition, this mode makes the program structure more intuitive by simplifying the complexity. The software system is separated by the basic parts of itself and also gives the functions of the basic parts. Professionals can be grouped by their own expertise:

    • Controller-Responsible for forwarding the request and processing the request.
    • View-Interface designer for graphical interface design.
    • Model-the programmer should be able to write the function (implementation algorithm, etc.), database experts for data Management and database design (can achieve specific functions).

    • model is used to encapsulate data that is relevant to the business logic of an application and how the data is processed. "Model" has the power to directly access data, such as access to a database. "Model" does not depend on "View" and "Controller", that is, the model does not care how it will be displayed or how it is manipulated. However, the changes in Model data are generally published through a refresh mechanism. To implement this mechanism, the view that is used to monitor this model must be registered in advance on this model, so that view can understand the changes that have taken place on the data model.
    • views enable the purposeful display of data (in theory, this is not required). There is generally no logic on the program in View. To implement the Refresh feature on the view, view needs to access the data model it monitors, so it should be registered with the data it is monitoring in advance.
    • The controller acts as an organizational function between different levels to control the flow of the application. It handles the event and responds. The "event" includes the user's behavior and changes on the data Model.

In Android application development, the design is based on the most basic MVC architecture.

is the basic pattern of MVC architecture in Android

    • Model objects store the data and business logic of the application, storing and managing application data.
    • The controller is the link between the View object and the model object, manages the data flow of the model object and the View object, and controls the response events such as triggering events.
    • The View object is the interface logic that the user feels.

Android application design is based on the MVC architecture, although strictly speaking, the activity is not simply the role of controller, and the current design patterns are many, such as MVP,MVVM, but original aim. Mastering the underlying MVC architecture allows you to get in touch with the latest design ideas and approaches, such as reducing development complexity, increasing code reuse, and more.

Android and MVC Design Patterns

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.