What is MVC?

Source: Internet
Author: User
Tags html form


Remember the first interview Phper (PHP is for me to quickly get started with another Web development language), people ask me mvc, I only know that M is Model,v is View,c is controller, specific to other knowledge I was ignorant, the result I was asked ask Sanbuzhi!! I didn't know how bad I was. So I decided not to make it clear! Find the following information


Big Small
Model-View-Controller (MVC) is a software design pattern invented by Xerox PARC in the 80 's for programming language Smalltalk-80, which has been widely used so far. It has been recommended in recent years as a design model for the Sun's Java EE platform and is being welcomed by more and more developers using ColdFusion and PHP. Model-View-controller mode is a useful toolbox that has many benefits, but also has some drawbacks.
How MVC Works

MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application. Using an MVC application is divided into three core parts: model, view, controller. Each of them handles their own tasks.

View
A view is an interface that the user sees and interacts with. For older Web applications, views are an interface of HTML elements, and in modern Web applications, HTML still plays an important role in the view, but new technologies are emerging, including Macromedia Flash and Image xhtml,xml/xsl , WML, and some other identity languages and Web services.

How to handle an application's interface becomes increasingly challenging. One big benefit of MVC is that it can handle many different views of your application. There is really no real processing happening in the view, whether the data is stored online or an employee list, as a view, it is simply a way to output data and allow the user to manipulate it.

Model
Models represent enterprise data and business rules. Of the three parts of MVC, the model has the most processing tasks. For example, it may use artifact objects such as EJBS and ColdFusion to process the database. The data returned by the model is neutral, meaning that the model is independent of the data format, so that a model can provide data for multiple views. Because the code applied to the model can be reused by multiple views only once, it reduces the repetition of the code.

Controller
The controller accepts the user's input and invokes the model and view to complete the user's needs. So when you click a hyperlink in a Web page and send an HTML form, the controller itself does not output anything and do any processing. It simply receives the request and decides which model component is called to process the request, and then uses which view to display the data returned by the model processing.

Now we summarize the process of MVC, first the controller receives the user's request and decides which model should be called to process it, then the model uses the business logic to process the user's request and return the data, and finally the controller formats the data returned by the model with the corresponding view and renders it to the user through the presentation layer.

What is MVC?

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.