The difference between PO, VO, BO, DAO, DTO, POJO (2)

Hierarchical domain model specification:

  • DO (Data Object): This object has a one-to-one correspondence with the database table structure, and the data source object is transmitted upward through the DAO layer.
  • DTO (Data Transfer Object): data transfer object, the object that Service or Manager transfers out.
  • BO (Business Object): Business object, an object that encapsulates business logic output by the Service layer.
  • AO (Application Object): Application object, an abstract reusable object model between the Web and Service layers, very close to the presentation layer, and the degree of reusability is not high.
  • VO (View Object): Display layer object, usually the object transmitted from the Web to the template rendering engine layer.
  • Query: data query object, each layer receives the query request from the upper layer. Pay attention to query encapsulation with more than 2 parameters, and it is forbidden to use the Map class for transmission.

Domain Model Naming Convention:

  • Data object: xxxDO, where xxx is the name of the data table
  • Data transfer object: xxxDTO, where xxx is the name related to the business field
  • Display object: xxxVO, xxx is generally the name of the web page
  • POJO is the collective name of DO/DTO/BO/VO, and it is forbidden to name it as xxxPOJO
1. PO: [persistent object], persistent object

It can be regarded as a java object mapped to a table in the database. It is a good choice to use hibernate to generate PO.

2. VO: [value object], value object

It is usually used for data transfer between business layers, and like PO, it only contains data. However, it should be an abstracted business object, which may or may not correspond to the table, according to the needs of the business.

PO can only be used in the data layer, and VO is used in the business logic layer and presentation layer. The operation of each layer belongs to its own data object, which can reduce the coupling between layers and facilitate the maintenance and expansion of the system in the future.

3. DAO: [data access object], data access object interface

DAO is Data Access Object data access interface, data access: as the name implies is to deal with the database. Sandwiched between business logic and database resources.

J2EE developers use the Data Access Object (DAO) design pattern to separate the underlying data access logic from the high-level business logic. Implementing the DAO pattern can focus more on writing data access code.

The DAO pattern is one of the standard J2EE design patterns. Developers use this pattern to separate the underlying data access operations from the upper-level business logic. A typical DAO implementation has the following components:

  1. A DAO factory class;
  2. A DAO interface;
  3. A concrete class that implements the DAO interface;
  4. data transfer object

Concrete DAO classes contain the logic for accessing data from a specific data source.

4. BO: [business object], business object

All entity classes representing "things" within the application domain that reside on the server and utilize service classes to assist in their responsibilities.

Five, DTO: [data transfer object], data transfer object

It is mainly used in places where a large number of objects need to be transferred, such as remote calls.

Six, POJO: [plain old java objects], simple Java objects

In fact, they are ordinary JavaBeans. The POJO name is used to avoid confusion with EJB, and the abbreviation is relatively straightforward; there are some properties and their getter and setter methods, which can sometimes be used as value objects or data transform objects.

Of course, if you have a simple operation attribute, it is also possible, but business methods are not allowed, and methods such as connection cannot be carried.

Guess you like

Origin blog.csdn.net/m0_60252632/article/details/131550583