Search code examples
javadaodtobusiness-logicbusiness-objects

Difference between business object and transfer object?


While many stackoverflow answers regarding this question exists, rarely do they clearly distinguish the difference between the two. As a result, I am having confusion in understanding them.

Here I am working with this pattern

Referring to the figure 9.1, both business object and transfer object are used. While definition of both are given along the lines as:

generally considered to be a class that represents an Entity, e.g. a Book or a Store. Such a class has certain properties like price, colour, width, isbn number etc. In Java or .NET, it consists of so-called setters and getters

Now DTOs have same definition. It appears to me like a Bean representing an object. So in a standalone application what could possibly be business object and DTO. Please distinguish between the two in terms of the pattern link above.


Solution

  • A DTO is used to transport the data from one layer to other, (for example from the data access layer to the model).

    A BO contains the Business Logic.

    But the most important thing in this patterns is to separate the layer, in order to make the software more easily maintained.

    For example, if you separate the data access layer, it doesn't matter if you are using a database to get the data, or a socket, or a plain text file separated with pipelines, you can change this and it will not affect the rest of the layers.