banner
指数爆炸

指数爆炸

我做了对饭 !
github
bilibili

Detailed explanation of various data models in architectural design [PO, VO, BO, Rich Domain Model ...]

When I came across these messy data models, I was really confused. The architecture design was also chaotic, and I didn't know how to derive the corresponding package names based on the data models. I also browsed various materials online, but no one explained it in a simple and understandable way, so I 整理了一下 based on my experience.

500

  • POJOplain old java object】ordinary Java object, can serve as the basis for other data models
    • VOvalue object】: A value object is an immutable object, with no unique ID identifier, used to represent a set of values【which means that if two value objects have the same properties, they are equal
      • Can contain simple business logic operations
      • VO usually overrides equals and hashCode methods for value-based comparison
    • PO / EntityEntity】: An entity must have a unique ID identifier, which means that if two entities have the same property values, they are not equal; PO is a Java object that maps to a database table【so PO and entity can be considered the same concept
    • DTOdata transfer object】: DTO is used to transfer data between different layers
      • Does not contain any business logic
    • Rich Model: Rich model = PO + business logic, if a PO contains business logic, then it is a rich model
      • BOBusiness object】: A business object contains business logic
        • Used only in the Service layer
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.