DSA Factory
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.

Quick check

What does the build() method of a builder typically do?

  1. AValidates the collected values and creates the final (often immutable) object
  2. BSets the first property
  3. 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.

Lock it in

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