MVC principles and the pros and cons of MVC patterns

Source: Internet
Author: User

First, the MVC principle
MVC is a program development design pattern, which realizes the separation between the display module and the function module. It improves the maintainability, portability, expansibility and reusability of the program, and reduces the development difficulty of the program. It is mainly divided into model, view, controller three layer.
1, model It is the main part of the application, including the Business logic module (Action,dao class in Web project) and Data module (Pojo Class). The model is independent of the data format, so 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
2. Views (view) the interface that the user interacts with, the view in the Web is generally composed of jsp,html
3. The controller receives the request from the interface and gives it to the model for processing in this process the controller does not do any processing just to make a connection to do it

Second, the advantages of MVC
1. You can create and use multiple views at run time for a model. The change-propagation mechanism ensures that all related views are in time to get model data changes, so that all associated views and controllers behave in a synchronous manner.
2, the view and the controller pluggable, allows the exchange of views and controller objects, and can be dynamically opened or closed according to demand, and even during the operation of object substitution.
3, the portability of the model. Because the model is independent of the view, it is possible to migrate a model independently to the new platform work. All you need to do is make new changes to the view and controller on the new platform.
4, the potential framework structure. The application framework can be built on this model, not just in the design of the interface.

Third, the shortcomings of MVC
1, Increases the complexity of the system architecture and implementation. For a simple interface, 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 connection between the view and the controller is too tight. 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, view low-efficiency 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, the general advanced interface tools or constructors do not support the mode. The cost of transforming these tools to accommodate MVC needs and to build separate parts is very high, which makes MVC difficult to use.

MVC principles and the pros and cons of MVC 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.