What is the MVC framework?

Source: Internet
Author: User

1. What is MVC

The Model View controller, which is the abbreviation for models-view-controllers, is a paradigm of software design that organizes code in a way that separates business logic, data, and interfaces, and aggregates business logic into a single component, while improving and customizing the interface and user interaction. There is no need to rewrite business logic. MVC is used to map the traditional input, processing, and output functions in a logical graphical user interface structure.

MVC is a three-tier architecture that uses encapsulated (layered) thinking to reduce coupling, making our systems more flexible and more scalable.

Model is the part of the application that handles 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 the data model.

A controller is the part of an application that handles data interactions. usually the controller is responsible for reading data from the view, controlling user input, and sending it to the model.

2. The advantages of MVC

(1) Multiple views share a model, which greatly improves the reusability of the code.

(2) Three modules are independent of each other, changing one does not affect the other two, so a good loose coupling component can be built according to this design pattern.

(3) The controller improves the flexibility and control of the application. The controller can be used to connect different models and views to complete the user's needs, so that the controller can improve the powerful means of constructing the application.

3. The drawbacks of MVC

(1) Increase the complexity of the system structure and implementation.

For simple pages, strict adherence to MVC, which separates the model, view, and controller, increases the complexity of the structure and may result in excessive update operations and reduced operational efficiency.

(2) The view is too tightly connected to the controller.

Views and controllers are separated from each other, but they do have a tight connection, the view has no controller, its application is very limited, and vice versa, which prevents them from being reused independently.

(3) A view of inefficient access to model data.

Depending on the model operator interface, the view may need to be called multiple times to obtain sufficient display data. Unnecessary frequent access to unchanged data will also compromise operational performance.

(4) Currently, some advanced interface tools or constructors do not support MVC.

The cost of transforming these tools to accommodate MVC needs and to build separate parts is high, resulting in the difficulty of using MVC.

In summary , for large applications that have a large number of user interfaces and complex business logic, MVC will give your software a new level of robustness, code reuse, and structure. Although it will take a certain amount of effort to initially build the MVC framework, it will greatly improve the efficiency of later software development in the long run. Therefore, we should consider the scope of application in the specific application,

4. Frame vs Design mode

(1) frameworks are often code reuse, and design patterns are reuse of design,

  Schemas are in between, part of code reuse, partial design reuse, and sometimes analysis can be reused.

There are three levels of reuse in software production:

Internal reuse, which is an abstract block that can be used publicly in the same application;

Code reuse, which combines common modules into libraries or toolsets to be used in multiple applications and domains;

Application framework reuse, which provides a common or out-of-the-box infrastructure for specialized domains for the highest level of reusability.

(2) The design pattern is a description of the recurring problems in an environment and the solution to the problem, which is more abstract than the framework.

The framework can be represented in code, can be directly executed or reused, and only instances can be represented in code for a pattern.

The design pattern is a smaller element than the frame. A framework often contains one or more design patterns, and the framework is always targeted at a particular application area, but the same pattern can be applied to a variety of applications.

It can be said that the framework is software, while design patterns are software knowledge.

(3) In short: The framework is a great wisdom for the division of Software design, design mode is a small skill, to solve specific problems, to improve code reuse rate, reduce coupling degree.

5. Summary

Through the study of MVC, we want to know that it is used to split the page and database access framework, reduce the coupling between the two, while the controller control, but also make the system more flexible, make our code more robust, more reusable, but everything has his scope of application, We can not think it is good, dare to 3,721 blind use, sometimes may be counterproductive, so the study of MVC also need us to slowly explore.

Reference documents:

http://blog.csdn.net/u010168160/article/details/43150049

What is the MVC framework?

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.