← Back to PatternPip

BUILDER / THE IDEA IN A MINUTE

Create the parts.
Then the whole.

Builder separates an object’s construction into explicit steps, so callers can assemble the parts they need before asking for the finished object.

The builder owns an unfinished draft. The product is the result. A caller chooses the steps; an optional director can coordinate a reusable sequence.

What changes?
The parts and steps used to construct an object.
What stays stable?
The product’s rules and the named construction operations.
Who chooses the steps?
The caller, or an optional recipe that coordinates them.

WATCH IT TAKE SHAPE

Build the parts. Keep the result.

Try it yourself

Add named parts to an unfinished draft. Build a report when it’s ready, then keep editing the draft to see what stays separate.

1 / CHOOSE NAMED STEPS

You choose the parts

Required parts first, or optional ones first. Build checks that the essentials are there.

2 / THE BUILDER

A working draft

0 of 2 required parts ready

BUILDER / CURRENT DRAFT

Title not set

Body not set

Optional parts may be left out.

3 / THE PRODUCT

A finished report

Created only when you call build()

Your finished report will appear here.

Add the required parts, then build.

Start with an empty builder. Add a title and body, then build your report.

Try this: add a title and body, then build. Add a chart or change the title. Your finished report stays the same until you build a new one.

This builder requires a title and body, keeps its draft after building, and returns independent snapshots. Reduced motion is on; changes appear immediately.

Useful when construction has real steps.

Many optional parts, repeated assembly recipes, or several representations built through similar operations can benefit from a dedicated builder.

More machinery is a tradeoff.

A constructor, factory function, options object, or Kotlin named arguments may be enough for simple data. Fluent method chaining alone does not make a useful Builder.

Choose your next step.