Das Builder-Pattern konstruiert komplexe Objekte Schritt für Schritt und trennt dabei die Konstruktion von der Darstellung. Es ist besonders nützlich für Objekte mit vielen Parametern oder optionalen Teilen und ermöglicht eine lesbare, flexible Objektkonstruktion statt unhandlicher Konstruktoren.
Das Problem, das Builder löst
Objects with MANY parameters (especially optional ones) lead to problems:
✗ huge constructors: new Pizza('large', true, false, true, 'thin', false, ...) →
unreadable (which boolean is what?); hard to use; error-prone
✗ many constructor overloads (telescoping constructors) → messy
→ Builder provides a clean, readable, step-by-step way to construct such objects.
