A request DTO has many optional fields and constructors are becoming unreadable. Which pattern should you reach for first?
Practice this question from Quiz: Design Patterns, with options and an explanation.
Question
A request DTO has many optional fields and constructors are becoming unreadable. Which pattern should you reach for first?
Option A — Correct answer
Builder
Builder makes optional fields readable and avoids huge constructors.
Option B
Adapter
Option C
Observer
Option D
Proxy
Explanation
Builder avoids telescoping constructors and makes complex object creation readable.