Free Design patterns lessonsDesign patterns · Stage 0 · Creating objects · Step 3
Builder
Constructing an object with many optional parts step by step, instead of a constructor with a dozen parameters. About 11 minutes.
What does the build() method of a builder typically do?
- AValidates the collected values and creates the final (often immutable) object
- BSets the first property
- CClones the builder
Show the answer
Validates the collected values and creates the final (often immutable) object. It's the single point where the object becomes real.
4 questions on this idea
Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.
Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve