MVC is a wide popular software design model. As early as 190s, IBM launched a Sanfronscisico project plan, in fact, the study of MVC design mode. Recently, with J2EE's maturity, it is becoming a design model recommended on the J2EE platform, and is also a design model that the majority of Java developers are very interested. The MVC mode is also gradually applied in PHP and ColdFusion developers and has a growth trend. With the rapid increase in network applications, MVC mode is undoubtedly a very advanced design idea for web applications. No matter which language you choose, no matter how complicated application, it can provide the most basic for you to understand the application model. Analyze methods, provide a clear design framework for your constructive products, providing a basis for your software engineering. MVC design idea MVC English is Model-View-Controller, that is, the input, processing, output flow of an application is separated by model, view, and controller, so that an application is divided into three layers - model layers, view layers, Control layer. View (view) represents the user's interactive interface, for web applications, can be summarized as an HTML interface, but it is possible for XHTML, XML, and Applet. As the complexity and scale of the application, the processing of the interface has also become challenging. An application may have many different views, and the MVC Design Mode is limited to the processing of the view only to the acquisition and processing of the data on the view, and the user's request is not included in the view on the view. Processing of business processes to transfer model (Model). For example, a view of a order accepts data from the model and displays the user, and passes the input data and requests of the user interface to the control and model. Model: It is the process of business process / status and business rules. The process of business processes is a black box operation for other layers, and the model accepts the data requested by the view, and returns the final processing result. The design of the business model can be said to be the most important core of MVC. At present, the popular EJB model is a typical application example. It has further divided from the angle of application technology to the model in order to make full use of existing components, but it cannot be used as a framework for application design models. It only tells you that some technical components can be used in this model design, thereby reducing technical difficulties. For a developer, you can focus on the design of the business model. The MVC design pattern tells us that the application's model is extracted by a certain rule, and the level of extract is important, which is also the basis for judging whether the developer is excellent. Abstract and specific can't be too far, it is not too close. The MVC does not provide a model design method, and only tells you that you should manage these models to make the model's reconstruction and improvement of reuse. We can use object programming to make a metaphor, and MVC defines a top class, telling it that you can only do this, but you can't limit you. This is very important to programmed developers. There is also a very important model of the business model that is the data model. The data model mainly refers to the data saving (continuous) of the physical object. For example, save one order to the database and get an order from the database. We can separate this model separately, and all the operations of the database are limited to this model. Controller can be understood as a request from the user, match the model with the view together to complete the user's request. The role of dividing the control layer is also obvious, it clearly tells you that it is a distributor, what kind of model chooses, what kind of view can be done, can do what kind of user request. The control layer does not do any data processing. For example, the user clicks on a connection, after the control layer accepts the request, does not process business information, which only passes the user's information to the model, tells the model, and selects a view that meets the requirements to return to the user. Therefore, a model may correspond to multiple views, and one view may correspond to multiple models.
The advantages of MVC are mostly using process languages such as ASP, PHP development web applications, and the initial development template is data programming of the mixed layer. For example, send a request directly to the database and display it with HTML, the development speed is often faster, but because the separation of the data page is not very straightforward, it is difficult to reflect the use of the business model or the reuse of the model. The product design is very resilient, it is difficult to meet the user's change needs. MVC requires a layering of the application, although it takes an additional work, but the structure of the product is clear, the application of the product can be better reflected by the model. First, the most important thing is that there should be multiple views to correspond to a model. Under the rapid changes in the current user needs, there may be a variety of ways to access applications. For example, the order model may have orders for this system, and there is an order of online orders, or orders for other systems, but the processing of orders is the same, that is, the processing of orders is consistent. Press MVC design mode, a order model, and multiple views to solve the problem. This reduces the copy of the code, which reduces the maintenance amount of the code, and once the model changes, it is easy to maintain. MVC design model
Second, since the data returned by the model does not bring any display format, these models can also be applied directly to the interface. Again, since an application is separated into three layers, sometimes change the one of the devices to meet the application. A change in business procedures or changes in business rules requires only the Model layer of the MVC. The concept of the control layer is also very effective, since it combines different models and different views together to complete different requests, the control layer can be said to include the concept of user request permissions. Finally, it is also conducive to software engineering management. Due to the different layers, each layer of different applications has some of the same features, which is advantageous to generate management program code through engineering and instrumentation. MVC's shortcomings MVC design implementation is not very easy, and it is relatively easy to understand, but it is relatively high for developers. MVC is just a basic design idea and requires detailed design planning. The stringent separation of models and views may make it difficult to debug, but it is easier to find errors. Experience shows that MVC is divided into three layers, meaning that the code file is increased, so for the management of the documentation needs. In combination, MVC is a very good basic model for building software, at least business processing and display separation, forcing application into models, views, and control layers, making you carefully consider the additional complexity of the application, integrating these ideas into In the architecture, the application will be increased. If you can grasp this, the MVC mode will make your application stronger, more flexible, and more personalized. Reprinted from: CCID