The MVC mode of Android

Source: Internet
Author: User

MVC Overview: 

The MVC pattern is a software architecture in software engineering, the mode (model)-view (view)-controler (Controller) abbreviation;

  The MVC pattern divides an interactive application into 3 components:

Model: The business logic layer that contains core functions and data and implements core business logic

View: Presentation layer, displaying information to the user

Controller: Control layer, process user input, and implement the view layer and model layer work together

MVC Application Areas:

  Interactive application with flexible HMI:

Flexibility to choose different information display methods

Flexibility to choose the user input method

  Different user interfaces are available for different user roles:

Different users have different permissions and operate differently

Model:

  A business logic layer that encapsulates business logic and data

Business logic (core of software)

Data and the functions that access them (view components use)

Procedures for performing specific application processing (control calls on behalf of the user)

The model is not visible to the user (M vs. v Independent)

The model is independent of a specific output representation or Input method (M independent of C)

The user can only operate the model via the controller (c is the bridge between M and V)

Views (view):

The presentation layer, which is the interface that the user sees and interacts with, usually implements the input and output functions of the data.

  Getting data from a model:

Implementation by State query function

Columns such as: Timed refresh

  To display information to the user:

Different views use different methods to render information

Each view component has an update function that is activated by the model change notification

This function is used by the building block Oh (when the model has changed), the view is re-aligned with the model

In the initialization phase, the view registers the request change notification (table) with the model

Control (Controller):

Control layer, play the role of controlling the entire business process, realize the view layer and the model layer work together.

Each view has a related controller component (one by one corresponds)

Users only interact with the system through the controller

  The controller component accepts events and translates them into inputs:

How events are sent to the controller is determined by the user interface platform

An event is translated into a plea for a model or view

If the behavior of the controller depends on the state of the model, then the controller also needs to register a plea change notification to the model

For example: The user clicks the button, the event response function of the button will respond to the action to process the user request

Change-Propagation mechanism:

  A model can be used for multiple views:

If the user changes the data in the model through a view's controller, other views that depend on that data should also reflect this change

Once the model's data has changed, the model needs to notify all relevant views to make corresponding changes

  Maintain consistency of data:

This can be done through the Observer (Observer) design pattern

The relationship and function diagram of the MVC component type:

   

The MVC mode of Android

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.