What are DTO and BO? What is the difference?

I know that DTO is a data transfer object, and BO is a business object. But what does that mean? When should I choose one by one? From what I understand, DTO is used only for data transfer and does not have business logic. Does this mean that the DTO does not have any properties of only the method (getter and setter)? But it still has BO properties. Can someone explain? Thanks.

+6
design business-objects
source share
2 answers

DTO is used to transfer data between layers / layers. For this purpose, it does not need methods, and sometimes it should not even have any methods - for example, when the DTO is exposed to a web service.

A business object is a smart object that contains data and methods that perform operations (modify data) on that object. When you open BO to the upper level, it can call your public object methods. Sometimes you don’t need this, and for this reason you create a DTO that offers only data, not methods.

DTO does not have to transmit all BO data. When you follow the rigorous DTO approach, you create custom DTOs for each operation that appears at your business level. For example, if your object has audit data, such as CreatedBy, ModifiedBy, CreatedDate, etc., and you create the Update method, your inbound DTO (with the updated object) should not have these properties, because the top level cannot modify them - only business logic can.

+11
source share

Typically, the DTO has relative static data at this point before the level arrives, but the BO can dynamically store the state and value of the stream flag; and BOs can also be self-sufficient to have validation or logical reorganization or judgment for any business logic; but a change in DTO depends on a change in the level of transmitted data ... But changes in BO have a wider range, for example, depends on a more dynamic update of the state of the business stream, a flag change, even the identification can be changed in real time, these are supposed to be captured and acting to reflect from BO, for example, for example, the balance from $ 200 becomes zero, or the balance from $ 2,000 to $ 5,000, then the transaction / identification or transaction status will change ... this is a big difference between DTO and BO.

+1
source share

All Articles