J2EE pattern • Integration
J2EEIntegrationJava example
Transfer Object solves a specific structural problem in the design.
Move grouped data across layers in one serializable package.
Pattern overview
J2EE pattern
Move grouped data across layers in one serializable package.
Intent
Carry multiple related values across process or layer boundaries efficiently.
Problem
Chatty boundary calls or repeated field-level access cause coupling and performance issues.
Solution
Wrap the boundary data into a dedicated transfer object.
Fit and tradeoffs
FamilyJ2EE
CategoryIntegration
Best used when
- For API payloads, remote calls, and cross-layer contracts.
Tradeoffs
- DTO sprawl can grow quickly without naming discipline.
- Transfer objects should not quietly become domain objects.
Java example
This example is intentionally compact so the pattern shape stays easy to see.
public record CustomerDto(String id, String email, String name, boolean active) {}