The Builder pattern is a creational GoF design pattern by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides that separates the construction of a complex object from its representation, so that the same construction process can create different representations. The algorithm that assembles the object stays independent of its parts and how they are put together, which suits step-by-step construction such as a fluent API for a query object.

GoF-Builder Pattern

Details
Full Name

GoF Builder Pattern (Creational)

Intent:

Separate the construction of a complex object from its representation so that the same construction process can create different representations.

When to Use:

  • When the algorithm for creating a complex object should be independent of the parts and how they are assembled

  • When the construction process must allow different representations

Prompt Example:

"Implementiere einen Builder nach GoF für das QueryObject, mit Fluent API für Filter, Sortierung und Pagination."