Project subcontracting for Java development

When we start to write a large-scale project, we can't just start writing down from the main function, we must have a clear logical idea and the transmission and interaction of data at all levels.

At the same time, when we write the project, we should separate different packages to do different things. For example, the view package is for the actual interface, and the dao package is for the data interaction of the database.

How to subcontract

Insert picture description here

tips : When we are writing the Service layer and DAO layer, we can create a corresponding interface first, and then implement it, which will facilitate code reconstruction in the future.

 

Personal understanding:

  Project hierarchical subcontracting is suitable for multi-person development and cooperation. It is best to set up a view in one interface, and at the same time, the comments must be set, in order: pass parameters from front to back, and pass return values ​​from back to front to judge whether it is true The SQL statement is executed (may not be returned), and the exception is handled in the Service layer. If multiple SQL statements are processed, they are also integrated and processed in the Service layer. 

effect:

  When the scale of the program is small, it can be completed by one person; but when the scale of the program is large, it is difficult for one person to complete the program. At this time, multiple people must cooperate to complete the program development.

        Multi-person cooperation will encounter the problem of task assignment. At this time, we will think that each person is responsible for completing one piece of the project. Then, the division of this piece of content requires us to adopt a layered (subcontracting) way to complete.

        Use the following figure (user registration function) to explain the common layering (subcontracting) in the project.

1. The role of the view layer: the view layer, that is, the interface in the project (input and output statements)

2. Controller layer function: control layer, obtain data on the interface, set data for the interface; hand over the functions to be implemented to the business layer for processing (passing the value to the back --- encapsulating the information entered by the user and requesting the background)

3. The role of the service layer: the business layer, the realization of functions, interact with the controller control layer and the data access layer DAO, and hand over the operation of the database to the DAO data access layer for processing (usually handle exceptions thrown by the dao layer)

4. The role of the dao layer: data access layer, used to manipulate the data of the database table (JDBC is responsible for dealing with the database, the returned row number row is not processed at this layer)

5. db database: here refers to MySQL

6. Domain entity package: store JavaBeans (entity classes, one class per table, it is best to create entity classes with the same name and number of tables in the database)

7, tools toolkit: store the tool classes used in the project (such as the tool classes packaged in the same part in JDBC)

8. test test package: store the code of the project function test (main method)

 

Source of this article:

https://blog.csdn.net/qq_36528734/article/details/93786723

https://www.cnblogs.com/21-forever/p/11014627.html

Guess you like

Origin blog.csdn.net/weixin_44893902/article/details/108926143