Model1 and model2

Source: Internet
Author: User

Two Java development modes are introduced in the DRP video, namely, model1 and model2. The difference is that model1 combines the presentation layer with the business logic layer. Model2 separates the business logic layer based on it. The following describes their respective architectures.

 

Model1 is a JSP-centered development model. In the model1 system, the client directly deals with JSP pages, responds to user requests, and returns processing results to users. In addition, rendering pages, data verification, and business logic processing are also done by them. As a result, a large amount of Java and HTML code is mixed on the JSP page.


Advantages:

1. Most of the functions are completed by JSP pages, and few classes need to be created, which is fast and simple to develop.

2. Suitable for small-scale enterprise development

Disadvantage: strong coupling between business logic and presentation logic leads to low code reusability, which is not conducive to maintenance and expansion.

The model2 mode is based on the design mode of the Model View Controller (MVC, Model-View-Controller. In the model2 system, a web project is divided into three layers, including the model layer (consisting of JavaBean, including Dao), view layer (JSP page), and control layer (consisting of servlet ). As shown in:




What is the processing process of model2? Customer requests mainly deal with servlet. Servlet is equivalent to a controller responsible for managing request processing and creating the objects required for JSP pages. At the same time, it decides which JSP page to send to the requester based on the request's business needs.

Advantages:

1. Separate the control layer from the model1 system. Improves code reuse rate and scalability, and reduces project maintenance costs;

2. perform their respective duties on the third layer and do not interfere with each other

Disadvantage: it is not suitable for small enterprise project development.


Conclusion: the essential difference between model1 and model2 lies in the idea of hierarchy. Nowadays, people develop more software based on engineering ideas. Therefore, development projects are becoming increasingly popular for maintenance, reuse, and scalability. The layered thinking of model 2 (MVC) also reflects this point. In addition, this layered thinking can better adapt to demand changes, better division of labor, and better management. For example, an artist can be responsible for interface design, logic, and database.


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.