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

preface

In daily work, we often see some abbreviations, BO, VO, DTO, etc., there are often BO=>VO, BO=>DTO and other codes in the code, if we are not familiar with these concepts, it is bound to have a certain impact on our understanding of the code. Today we will take a look at some common business objects in work and explain their usage scenarios.

The business Object

DAO (Data Access Object)

In the three-tier architecture of Java server development, it is divided into Controller, Service and DAO. The data access layer is responsible for data interaction with the database.

The main function of layering is decoupling. Specifically, the DAO layer encapsulates access to the database: add, delete, change, and review, without business logic, just meet the requirement of obtaining specified data according to a certain commit.

The Service layer, on the other hand, focuses on business logic, and all database operations are implemented through the DAO layer.

VO (Value Object/View Object: Value Object/ Presentation layer Object)

VO from the name is mainly used to show the data. For example, the interface of web page and APP. It can be understood as JSON.

Compared with DTO, VO is more about business explanation. VO will select some or all fields of DTO to display according to business needs.

BO (Business Object)

BO encapsulates business logic as an object (the concept of business logic is important). This object can contain one or more other objects.

Throughout the request process, we construct a BO, and in the rest of the process, we operate by passing the BO, including DTO, VO, and so on.

DTO (Data Transfer Object)

DTO can be understood as the encapsulation of data transmitted between interfaces. Mainly used for remote calls where a large number of objects need to be transferred.

PO (PerisPeristant Object: Persistent layer Object)

A PO is a database record. When storing in the database, we will build a PO object.

What is the difference between a PO object and a DTO object?

PO records all the fields of a record in the database for insertion into the database. DTO is used to fetch partial fields of a record in a database. This has two advantages:

  1. Increases the speed of data transfer (reduces the number of transfer fields)

  2. Can hide back-end table structures

Reference documentation

  • VO, BO, PO, DO, DTO

  • How to distinguish entity, BO, VO, Po, DTO, and POJO?