Java EE Learning notes--MVC Framework

Source: Internet
Author: User
Tags java web

MVCis a software design pattern that was originally designed toSMALLTALK-80language brought up, but later inJSPIt has been widely used in development and becomeSunrecommended by the companyjava EEthe design pattern of the platform. Sunproposed by the companyModel2The development model is based onMVCThe application of design patterns inWebin application development,MVCThe framework is widely used and is especially suitable for large and complex project development.

MVCThe framework is the model-View-Controller (Model-view-controller) design pattern. Among them,MrepresentModel,VrepresentView,CrepresentController. MVCThe core idea is that the Data Service processing function (model), presentation function (view) and control function (control layer) of an application in the future3a different part of the implementation. MVCThe goal is to increase the reusability of code, reduce the degree of coupling of data description and application operations, and improve the readability of the code. At the same time, it can also make the software maintainability, scalability, repairable, flexibility and encapsulation greatly improved.

Model: The model is the business processing layer of the application, responsible for the processing of all business processes and the development of business rules. The model processes the request data for the views forwarded by the Controller and returns the final processing results to the view.

View: view is the presentation layer of the application , representing the user interaction interface. In the web application, the interaction interface may be html xml the interface, applet interface or other interface. An application can even correspond to multiple views. mvc

Controller: The role of the controller is actually a distributor. Responsible for deciding which model components to forward the request data to, and deciding what views to choose to display the data returned by the model. As with views, the controller itself does not process any business information.

based on MVC application to a user when requesting the processing process as follows:

1 . the end user issued a request through the application that was forwarded to the Controller(Controller).

2. when the controller receives the request, it checks the request and then decides what business logic to use to process the request, when the Controller forwards the request to a corresponding business component to process.

3. The model contains all the business components that handle the user's request, and also performs all the data access required by the user. Any data retrieved on behalf of the end user query is packaged and returned to the controller.

4. The controller receives the data returned from the model, selects the corresponding view that displays the data, and returns the view to the user.

MVC The advantages:

1. facilitates the maintenance of the program and the extension of the function. in the MVC Framework,3 tiers are functionally and structurally independent of each other, and each layer is responsible for implementing their respective functions. If a layer's requirements change, you only need to change the code in the corresponding layer without affecting the code in the other layers.

2. The division of labour in favour of development. in the MVC Framework, the Division of labor in development can be achieved well by dividing the application into 3 tiers. Web developers can develop a view layer, people familiar with the business can develop the business layer, and other people can develop the control layer.

3. facilitates the reuse of components. The hierarchical development pattern of the MVC framework facilitates the reuse of components. If the control layer can become a stand-alone component, the presentation layer can be made into a common interface, and the business processing layer can be a stand-alone functional module that can be applied to other project development.

MVC The disadvantages:

1. the same shortcomings as the design pattern, increased the complexity of the project solution, while improving the efficiency of the development of large-scale projects at the same time reduce the development efficiency of small projects, processing process complexity caused by the decline in performance.

2. the failure to address the question of how to provide Rich Client still requires considerable development. With Rich-Client inability to avoid JavaScript, the traditional MVC framework almost never takes JavaScript into account. Simply ignoring JavaScript has no help in improving the performance of the page, and the development of complex JavaScript is the responsibility of programmers.

3. the development of View in MVC still employs a form based request / response pattern, and therefore still has all the drawbacks of this pattern. MVC does not solve all the problems of the presentation layer, it only solves some of the important issues in the presentation layer. In addition to being meaningful to developers, MVC does not bring a lot of business value to end users, and end users are concerned with the external quality of the software rather than the intrinsic quality that programmers care about.

MVCor a very good software design model, orSunnor will it be recommended asjava EEdesign model, but also popular for so many years. Any design pattern has its inherent limitations, and there is no way to solve all the problems. So say,MVCThere is no shortcoming in itself, just different understanding and different realization brought different problems. As developers of us, is to constantly pursue perfection to make up for the shortcomings of the implementation. ibm/360The father of Brooks (Frederick Phillips Brooks, Jr.said: "I think the most difficult part of learning programming is the way to do things in the direction of the pursuit of perfect adjustment." "Java WebThere are many based onMVCframework, as everyone knows.Struts, the stamina of theSpring MVC, there areWebWork,Turbine,MaverickFramework.



</

Related Article

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.