In the current Internet framework, we have heard most about the three-tier architecture, mainly controller, serivce, dao, so we introduced a series of packet naming to distinguish different layers, such as entity, web, dao, Then there are VO, DTO, DO, PO, I have a general understanding today and take notes~

Concept:

  • VO: value object value object/view object presentation layer object
  • DTO (TO): Data Transfer Object
  • DO: Domain Object is a tangible or intangible business entity abstracted from the real world.
  • PO: persistent object
  • POJO: plain ordinary java object
  • BO: business object
  • DAO: data access object

In fact, we don't need to distinguish them very carefully. We can just know about them and merge them together.

Working model:

The user sends a request (possibly filling in a form), and the form data is matched as VO in the presentation layer.

The presentation layer converts the VO into the DTO required by the corresponding method of the service layer and transmits it to the service layer.

The service layer first constructs (or reconstructs) a DO according to the data of the DTO, and calls the business method of the DO to complete the specific business.

The service layer converts the DO into the PO corresponding to the persistence layer (you can use the ORM tool or not), calls the persistence method of the persistence layer, passes the PO to it, and completes the persistence operation.

A reverse operation, such as reading data, is converted and transferred in a similar way.

Simple diagram:

 The Concept, Use and Use of VO, DTO, DO, PO and POJO

Simple memory method: take SSM as an example

DO: Corresponding database table structure
VO: generally used for front-end display
DTO: used for data transmission. (Both interface input parameters and interface return values are acceptable)

 Controller layer: public List<UserVO> getUsers(UserDTO userDto); Service layer: List<UserDTO> getUsers(UserDTO userDto); DAO layer: List<UserDTO> getUsers(UserDO userDo);

Reference link:
https://www.cnblogs.com/zhangshiwen/p/7945064.html
https://www.cnblogs.com/jpfss/p/9947811.html
https://www.cnblogs.com/zxf330301/p/6534643.html
https://blog.csdn.net/u011870547/article/details/81077153

Article Contents