architect-handbook

Software Architect Handbook

View on GitHub

Data Transfer Object

An object that carries data between processes in order to reduce the number of method calls.

Overview

When you’re working with a remote interface, each call to it is expensive. As a result you want to reduce the number of calls, and that means that tansfering more data wit each call.

One solution is to create a Data Transfer Object that can hold all the data for the call. It needs to be serializable to go across the connection. Usually an assembler is used on the server side to transfer data between the DTO and any domain objects.

How It Works

For example, if a remote object requests data about an order object, the returned Data Transfer Object will contain data from the order, the customer, the line items, the products on the line items, the delivery information, all sorts of stuff.

When to Use It