Thursday, 23 January 2014

What is DTO Class



Data transfer object (DTO) is an object that carries data between processes. The motivation for its use has to do with the fact that communication between processes is usually done resorting to remote interfaces (e.g. web services), where each call is an expensive operation. Because the majority of the cost of each call is related to the round-trip time between the client and the server, one way of reducing the number of calls is to use an object (the DTO) that aggregates the data that would have been transferred by the several calls, but that is served by one call only.
The difference between data transfer objects and business objects or data access objects is that a DTO does not have any behavior except for storage and retrieval of its own data (accessors and mutators). DTOs are simple objects that should not contain any business logic that would require testing.
Data transfer object (DTO), formerly known as value objects or VO, is a design pattern used to transfer data between software application subsystems. DTOs are often used in conjunction with data access objects to retrieve data from a database.
DTOs are called Data Transfer Objects because their whole purpose is to shift data in expensive remote calls.

A Wrapper Class  is where you declare a Class as a container for an sObject to extend the functionality only for display or processing purposes.DTO is a slightly dumbed down version of such a wrapper .


When designing a data transfer object, you have two primary choices: use a generic collection or create a custom object with explicit getter and setter methods.

 Figure 1: Remote calls without a DTO  
Figure 2: Reducing the number of calls by using a DTO




No comments:

Post a Comment