Name

Data Transfer Object (DTO)

Goal

Improve performance by reducing the number of objects passed between tiers (Figure B-2).

Classes in the DTO pattern
Figure B-2. Classes in the DTO pattern

Participants

Business objects

Create DTOs for sending data, or use values in received DTOs.

DTO

Stores data for transport between layers.

Presentation tier objects

Create DTOs for sending data, or use values in received DTOs.

Interactions

A presentation tier object requests data from the business tier. The business object reads the data and copies it into a DTO for transport. The presentation tier object uses the data in the received DTO. The presentation tier object modifies the received DTO or creates a new one to transport data back to the business tier.

Notes

DTOs may be data objects used within the business objects themselves, or dedicated classes for transporting data. DTOs often follow JavaBean semantics, but this is not a requirement.

Get J2EE Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.