When and Why to Use VO, BO, PO, DO, and DTO in Java Projects
This article explains the roles of View Object (VO), Business Object (BO), Persistent Object (PO), Domain Object (DO), and Data Transfer Object (DTO) within the MVC architecture, discusses when they are beneficial for small versus large Java projects, and offers practical naming conventions to improve code maintainability and scalability.
Today we discuss VO, BO, PO, DO, and DTO, aiming to give you a clear understanding of these concepts.
Concept
Before diving into specifics, let’s briefly review the MVC development model.
MVC simple definition:
Mlayer handles database interactions.
Clayer handles business logic.
Vlayer presents data to users (for non‑separated front‑back projects, the V concept is more intuitive).
VO, BO, PO, DO, DTO are the entity transfer objects that travel between these M, V, C layers.
Definitions
VO (
View Object) – View object , used in the presentation layer to encapsulate all data required by a specific page or component.
DTO (
Data Transfer Object) – Data transfer object , originally from J2EE design patterns to reduce remote calls; here it serves as the object exchanged between the presentation and service layers.
BO (
Business Object) – Business object , encapsulates business logic and may contain one or more other objects.
PO (
Persistent Object) – Persistent object , maps one‑to‑one with database tables; each table field corresponds to a PO attribute.
DO (
Domain Object) – Domain object , an abstract representation of a real‑world business entity.
Is It Necessary?
Should a project really define VO, BO, PO, DO, DTO?
It depends on the project’s purpose.
If the project is a small, simple MVC application with a single‑developer approach, I recommend using plain POJOs for data exchange instead of the full set of objects, as the goal is rapid delivery.
For larger, continuously iterated team projects, adopting VO, BO, PO, DO, DTO and establishing a shared standard improves collaboration.
In complex business scenarios with high collaboration requirements, adhering to these conventions enhances extensibility and readability.
It makes class semantics clearer, so developers can quickly understand each class’s purpose.
Overall, these practices boost a project’s
scalability,
maintainability, and
readability, leading to better economic benefits.
Summary
This short article concludes that whichever approach you choose, the key is to define a consistent collaborative standard within the team.
There is no universally "best" or "worst" method; the team’s agreed convention ultimately enhances extensibility, maintainability, and readability, reducing bug rates.
Naming conventions:
Data objects:
xxxPO(or
xxxDO) where
xxxis the table name.
Data transfer objects:
xxxDTOwhere
xxxreflects the business domain.
View objects:
xxxVOwhere
xxxis usually the page name.
Business objects:
xxxBOwhere
xxxis the business name.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.