Builder
Constructs a complex object step by step, separating construction logic from the object's final representation — avoids telescoping constructors with many optional parameters.
Why we need this / what value this brings
Makes constructing a complex object readable and safe, avoiding a constructor with 8 positional boolean/optional parameters that are easy to mix up.
When to use this
An object has many optional parameters or must be constructed in a specific multi-step sequence.
How to use or implement this
Chain method calls that each set one piece of the object, ending in a .build(); in Python, keyword-only arguments or a Pydantic model often achieve the same goal more simply.
Research questions
- Any place in Localz's backend where a function takes 6+ optional parameters would benefit from a builder (or, in Python, keyword-only args / a Pydantic model) instead.
- See Builder Pattern's "Common pitfall" section — a builder is only worth the ceremony if
.build()actually centralizes cross-field validation; check whether any candidate site found above has that kind of validation need before introducing one.