Vo, Bo, Po, Dao, and pojo (1)

Source: Internet
Author: User

Po: persistant object
Persistent objects can be viewed as Java objects mapped to tables in the database. The simplest Po is to correspond to a record in a table in the database. A set of PO can be used for multiple records. PO should not be included
The advantage of any operations on the database is that one record can be processed as an object, which can be easily converted to other objects.

VO: Value Object
Value Object. It is usually used for data transmission between business layers. Like Po, it only contains data. However, it should be an abstract business object, which can correspond to a table or not. This is based on the business needs.
Same as DTO (data transmission object), transmitted on the web.
The viewobject presentation layer object mainly corresponds to the Data Objects displayed on the interface. For a Web page, or a SWT or swing interface, use a Vo object to correspond to the value of the entire interface.

Dao: Data Access Object
Data access object, which is used to access the database. It is usually used in combination with Po. Dao contains various database operation methods. This method is used in combination with Po to perform operations on the database.
There is almost no possibility or need to convert each other. It is mainly used to encapsulate access to the database. With pojo, pojo can be persistently converted into Po, and PO can be assembled into vo and DTO.

Bo: Business
The object Business Object encapsulates the Java object of the business logic. by calling the DAO method and combining Po and VO for business operations, the main function is to encapsulate the business logic as an object. This object can be
To include one or more other objects. For example, a resume includes educational experience, work experience, social relationship, and so on. We can correspond the educational experience to a po, the work experience to a po, and the society
The link corresponds to a po. Create a bo object to process the resume. Each Bo contains the Po. In this way, we can process the business logic for Bo.

Pojo: plain ordinary Java object
Simple (Rule-free) Java object. I personally think it and others are not at the same level. Vo and PO should both belong to it. in my opinion, pojo is the most common and variable object and is an intermediate
It is also the most common object for us to deal. After a pojo is persisted, the PO directly uses it for transmission. During the transfer process, DTO is directly used to correspond to the presentation layer, that is, vo.

Dto: Data Transfer
Object Data Transmission objects are mainly used for remote calls and other places where a large number of objects need to be transferred. For example, if a table has 100 fields, the corresponding Po has 100 attributes. However, only
To display 10 fields, the client uses the Web
Service to obtain data, there is no need to pass the entire Po object to the client, then we can use the DTO with only these 10 attributes to pass the results to the client, this will not expose the server table
Structure. After the client is reached, if this object is used to display the corresponding interface, then its identity will be changed to VO


To sum up, I think what is an object? O depends on the specific environment. In different layers and applications, the object identities are different, in addition, the conversion of object identities is quite natural. Just like you for your wife
A husband is a child of a parent. The original intention of designing these concepts is not to expose people, but to better understand and process various logics, so that everyone can better deal with problems in an object-oriented way.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.