Jump to content

Data transfer object

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ruidfigueiredo (talk | contribs) at 18:16, 4 October 2013 (DTOs were being incorrectly described. As its author points out (Martin Fowler) they were introduced in the context of remote interfaces, whose previous version of the document did not even mention). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Data transfer object (DTO)[1][2] 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[2]. 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 be transferred by the several calls, and that is served by one call only[2].

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.[1]

See also

This pattern is often incorrectly used outside of remote interfaces. This has triggered a response from its author[3] where he reiterates that the whole purpose of DTOs is shift data in expensive remote calls.


See also

Note: A Value object is not a DTO. The two terms have been conflated by Java developers in the past.

References

  1. ^ a b MSDN (2010). Data Transfer Object. Microsoft MSDN Library. Retrieved from http://msdn.microsoft.com/en-us/library/ms978717.aspx.
  2. ^ a b c Fowler, Martin (2010). Data Transfer Object. Patterns of Enterprise Application Architecture. Retrieved from http://martinfowler.com/eaaCatalog/dataTransferObject.html.
  3. ^ LocalDTO. Retrieved from http://martinfowler.com/bliki/LocalDTO.html.