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.
Ladislav Mrnka
source share