Java · Medium · Pro
Builder vs telescoping vs records for DTOs?
JavaDesign PatternsSeniorOOP
DTO shape trade-offs
Telescoping constructors explode as fields grow. Builders add fluent optional fields and validation at build(). Records give compact immutable carriers with generated equals/hashCode—ideal when the object is pure data.
| Style | Best for | Limitation |
|---|---|---|
| Record | Immutable API responses, events | No gradual construction; validation in compact ctor |