Question

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.

Was it helpful?

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.

OTHER TIPS

That article defines:

The BusinessObject represents the data client. It is the object that requires access to the data source to obtain and store data. A BusinessObject may be implemented as a session bean, entity bean, or some other Java object, in addition to a servlet or helper bean that accesses the data source.

and

This represents a Transfer Object used as a data carrier. The DataAccessObject may use a Transfer Object to return data to the client. The DataAccessObject may also receive the data from the client in a Transfer Object to update the data in the data source.

Surely you can see the difference between a class that wants to obtain and store data in a data source, and an object that simply carries data between layers?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top