MVC Programming Patterns

Source: Internet
Author: User

MVC Programming Patterns

MVC is a pattern of creating WEB applications using MVC (Model View Controller-View-controller) Design:

Model (models) represent the core of the application (such as a list of database records).

View displays data (database records).

The controller (Director) processes the input (writes to the database record).

The MVC pattern also provides complete control over HTML, CSS, and JavaScript.

Model is the part of your application that handles application data logic.

Typically, model objects are responsible for accessing data in the database.

View is the part of the application that handles the display of data.

Typically views are created from model data.

A controller is a part of an application that handles user interaction.

Usually the controller is responsible for reading data from the view, controlling user input, and sending data to the model.

MVC layering helps you manage complex applications because you can focus on one aspect at a time. For example, you can focus on view design without relying on business logic. It also makes testing of applications easier.

The MVC hierarchy also simplifies group development. Different developers can develop views, controller logic, and business logic at the same time.

MVC Pattern Structure

The MVC pattern divides the application into three parts of models, views, and controllers:

1. View: Presentation of data.

A view is an interface that the user sees and interacts with. The view displays relevant data to the user and can receive input data from the user, but it does not perform any actual business

Acting Views can query the model for business status, but cannot change the model. The view can also accept data update events emitted by the model to update the user interface synchronously.

2. Model: Apply object.

The model is the body part of the application. The model represents the business data and the business logic; it is responsible for notifying the view part when the data changes, and a model can be for multiple visual

Figure provides data. Because the same model can be reused by multiple views, the reusability of the application is improved.

3. Controller: Logic processing, controlling entity data to show on view, call model to process business request.

The controller receives the request and invokes the corresponding model component to process the request, and then invokes the corresponding view to display the data returned by the model.

MVC mode operating mechanism

As shown in the MVC pattern run mechanism:

All requests that the user submits to the server are taken over by the controller. After accepting the request, the Controller is responsible for deciding which model should be called for processing, and then the model is based on

The user requests the corresponding business logic processing and returns the data; the controller invokes the corresponding view to format the data returned by the model and renders it to users through the view.

A model is a module that encapsulates the business logic and data.

The controller calls these modules (Java is often implemented with Servlets, and many frameworks use Struts2 to implement this layer).

The view is primarily what you see, such as interactive interfaces.

MVC Programming Patterns

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.