Skip to content

Builder

Stable ID: pattern.builder
Kind: design-pattern
Status: stable
Source: skill/references/design-patterns/builder.md

Purpose

Construct a complex value through readable, validated steps while keeping invalid intermediate state controlled.

Use when

  • Construction has many optional values, ordering rules, or validation constraints.
  • Tests benefit from clear domain-valid defaults.

Avoid when

  • A constructor or named factory with a few fields is clearer.
  • The builder duplicates setters without enforcing meaning.

Applicability

  • Languages: any, python, q-kdbplus, cpp, rust, dart-flutter, typescript
  • Related entries: component.validation, component.testing-utilities