DO VO BO DTO POJO concept recording

Number 1: DAO

  DAO (Data Access Object) is an object-oriented database interface. It is responsible for the operation of the persistence layer and provides an interface for the business layer. It is mainly used to encapsulate the access to the database. Common operations are nothing more than CURD. We can also think that a DAO corresponds to a POJO object, which is located between business logic and database resources, and can be combined with PO to perform related operations on the database.

  Number 2: PO

  PO (Persistent Object) persistence layer object, it is composed of a set of attributes and attribute get and set methods, the simplest PO corresponds to a record in a table in the database (that is, we can put the database table A record of is understood as a persistence layer object), multiple records can use a collection of PO, and the PO should not contain any operations on the database. The attributes of PO correspond to the fields of the database table one-to-one. In addition, the PO object needs to implement a serialization interface.

  Number 3: BO

  BO (Business Object) business layer object is a simple real-world software abstraction, usually located in the middle layer. The main function of BO is to encapsulate business logic as an object, which can include one or more other objects. Take an example of a job application resume. Each resume includes education experience, project experience, etc. We can make education experience and project experience correspond to a PO, so that when we create a BO object corresponding to the job resume to process the resume, let each All BO includes these POs.

  Number 4: VO

  VO (Value Object) value object is usually used for data transfer between business layers. Like PO, it only contains data, but VO should be an abstracted business object, which can correspond to a table or not. This is based on Business needs. If the pots and pans are the corresponding business objects, then the entire cupboard is a value object. In addition, VO can also be called a page object. If it is called a page object, then it represents the object of the entire page display layer, and it can also be assembled from the required business objects.

  Number 5: DTO

  DTO (Data Transfer Object) data transfer objects are mainly used for remote calls and other places that require a large number of objects to be transferred. For example, if we have a transaction order table with 25 fields, then the corresponding PO has 25 attributes, but our Only 5 fields need to be displayed on the page, so there is no need to pass the entire PO object to the client. At this time, we only need to pass the DTO with only 5 attributes to the client, and if this object is used to correspond The display object of the interface, then its identity is changed to VO at this time. There are two benefits of using DTO, one is to avoid transmitting too much useless data, and to improve the transmission speed of data; the other is to hide the back-end table structure. The common usage is: assemble the requested data or attributes into a RequestDTO, and then assemble the response data or attributes into a ResponseDTO.

  Number 6: POJO

  POJO (Plain Ordinary Java Object) simple Java objects are actually ordinary JavaBeans, which are abbreviations created to avoid confusion with EJB (Enterprise JavaBean). POJO can essentially be understood as a simple entity class, which has some properties and classes with getter and setter methods. There is no business logic, no business methods, or methods such as connection. POJO is the most flexible object in the JavaEE world. In a simple system, if there are POJOs from the database to the page display, it can be a DTO; if there are POJOs from the database to the business process, it can be a BO; if From the database to the display of the entire page, it can also be VO.

reference

Guess you like

Origin blog.csdn.net/qq_33371766/article/details/106887710
Recommended