Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

👨🎓 author: Java Academic Conference

🏦 Storage: Github, Gitee

✏️ blogs: CSDN, Nuggets, InfoQ, Cloud + Community

💌 public account: Java Academic Party

🚫 special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.

🙏 Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.

☠️ Hold on to your dreams and fly without wings.

👋 Hello! I’m your old friend Java Academic Party. Today I’m going to share with you some common development models. These models are simplified step by step from complex to simple, resulting in less coupling and higher code utilization between development codes.

System development model

  • System development model, or system architecture, refers to the large structure that integrates application systems. There are two commonly mentioned systems structures: three-tier architecture and MVC. The two structures are both different and related. However, these two structures are used to reduce the coupling degree between system modules.
  • The system development model of traditional javaWeb project has four stages: pure JSP, JSP+JavaBean Model1, MVC Model2, MVC+ three-tier architecture.

1. JSP development model

  • “Pure JSP” development model will be all business logic, data display functions are completed by JSP pages. Its disadvantages are obvious: JSP page code structure is messy, display function and business code is not separated, maintenance and upgrade is quite troublesome…
  • At this point, JSPS are used to both process the business and display the content.
  • This model does not have just one JSP, but multiple jumps between JSPS.

2. The JSP + JavaBean Model1

  • JSP is mostly used to display content, but there is also a part used to deal with business, JSP pages also assume a large number of request parsing, business processing functions.
  • A JavabBean (that is, a Java class) is used to handle business. Part of the business in the JSP is separated from the JSP.
  • There is not only a JSP and a JavaBean, but also multiple jumps between them.

2.1 the JavaBean

  • Javebeans can be divided into two categories according to the specific concept: generalized Javabeans and Javabeans.

The so-called generalized Javabeans are Java classes in the general sense, which have two main functions: carrying data and business processing. So generalized Javabeans are divided into two categories: data-hosted beans and business-logic hosted beans.

  • Data-hosted beans are entity classes that are specifically used to host business data, such as Student, User, and so on
  • Business process beans refer to servlets or Dao objects that are specifically designed to handle user-submitted requests.

Chivalrous Javabeans refer to Java classes that comply with the “Javabeans” specification proposed by SUN. According to the JaveBean specification, Java classes that satisfy the following four points are called Javabeans:

  • The class needs to be public, i.e. public class…
  • This class needs to implement the Serializable interface.
  • The class requires a no-argument constructor, either default or display-defined.
  • If the class has member variables, they must be private, and public getters and setters for these private member variables must be provided.

In a real project, entity classes would typically be defined as chivalrous JaveBeans. That is, the data-carrying beans of a generalized JaveBean are generally defined as chivalrous Javabeans that meet the “JavaBean specification.”

3.MVC Development mode (Model2 of MVC)

Note: Model2 refers to the MVC development pattern

MVC, Model, View, Controller, Controller.

  • View: provides a user interface for direct interaction with users.
  • Model: A module that holds data and performs calculations on user-submitted requests. They fall into two categories: data hosting beans and business processing beans. The so-called data hosted Bean refers to entity class, specialized users to host business data, such as Student, User, etc. Business process beans refer to servlets or Dao objects that are specifically designed to handle user-submitted requests.
  • Controller: indicates a Controller. It is used to forward the user request to the corresponding Model for processing, and provide the corresponding response to the user according to the calculation results of Model.

4. Three-tier architecture

  • In order to conform to the idea of “high cohesion and low coupling”, the three-tier architecture divides each functional module into three layers: presentation layer (UI), business logic layer (BLL) and data access layer (DAL). Interfaces are used to access each other between the layers, and entity class (Model) of the object Model is used as the carrier of data transmission. The entity classes of different object models generally correspond to different tables in the database, and the attributes of the entity classes are consistent with the field names of the database tables

Three-layer architecture: View layer View, Service layer Service, persistence layer Dao.

  • View layer: Presentation layer, View layer, also known as Web layer for Web development. The code to receive user-submitted requests is written here.
  • Service layer: business layer, logical layer. The business and logic of the system is mostly done here.
  • Dao layer: persistence layer, data access layer. The code to operate directly on the database is written here. DAO is a Data Access Object.

In order to reduce the coupling degree of each layer, abstract-oriented programming is adopted in the three-layer architecture programming. View is the upper layer and Service is the lower layer. That is, calls from the top to the bottom are implemented through interfaces. The real service provider from the lower layer to the upper layer is the lower interface implementation class. The service standards (interfaces) are the same.

5.MVC+ three-tier architecture

MVC+ three-tier architecture development model is the most common development model in = traditional JaveWeb projects.

The so-called “MVC+ three-tier architecture” development Model mainly refers to that the MVC business processing Model is divided into two layers: Service layer and Dao layer, which are respectively used to deal with business logic and persistence operations.

  • Blue is a three-tier architecture, and purple is MVC. The Model layer of MVC is divided into Service and Dao.

6. SMS Student System Management System

  • This project is not written here. If you need it, please consult me in the following ways.

For the above project source code, click planet 🌍 for free access to planet (Github address) if there is no Github small partner. You can search 🔍 wechat public number: Java academic party, 📭 send SMS, free to send everyone the project source code, the code is tested by xiaobian personally 🔧, absolutely reliable, free to use.

——-💘 after watching the big guys can pay attention to the xiaobian, will always update the small skills, free to share with you!! 💝 — — — — —