MVC framework Pattern (ii)

Source: Internet
Author: User

The previous article gave a brief overview of the MVC framework pattern and, at the end of the article, gives a logical diagram of how MVC3 components work with each other, and in this article we'll go further to model-view-controller Their respective concepts and the principles of their co-operation.

models (model)
    • Business logic. Encapsulates the business logic and data
    1. Business logic (core of software)
    2. Data and the functions that access them (view components use)
    3. Procedures for performing specific application processing (Controller calls on behalf of the user)
    • The model is not visible to the user (M and v are independent)
    • Model independent with specific output representation or input mode (M vs. C Independent)
    • The user can only operate the model via the controller (c is the bridge between M and V)
views View
    • The presentation layer. is the interface that the user sees and interacts with, and usually implements the input and output functions of the data.
    • Get the data from the model. Implemented by State query functions (e.g., timed refresh)
    • Displaying information to users
    1. Different views use different methods to render information
    2. Each view component has an update function that is activated by the model change notification
    3. Once the function is activated (the model has changed), the view will be re-aligned with the model
    4. During the initialization phase, the view enlists the model to request a change notification
controller Controllers
    • Control layer. Play the role of controlling the whole business process, and realize the collaborative work between view layer and model layer.
    • Each view has a related controller component (one by one corresponds)
    • Users only interact with the system through the controller
    • The controller component receives the event and translates it into an input
    1. How events are sent to the controller is determined by the user interface platform
    2. The event is translated into a request for a model or view
    3. If the behavior of the controller depends on the state of the model, then the controller also needs to register the request change notification to the model (for example: the user clicks the button, the button's event response function will take appropriate action to process the user request)
Change - propagation mechanism
    • A model can correspond to multiple views
    1. 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
    2. Once the model's data has changed, the model needs to notify all relevant views to make corresponding changes
    • Maintain consistency of data
    1. This approach can be done through the Observer (Observer) design pattern

MVC framework Pattern (ii)

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.