🎨 Design Patterns (Gang of Four)
Beginner
What is the Builder design pattern?
Answer
The Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to produce different representations. Instead of a constructor with many parameters (a "telescoping constructor" anti-pattern), a builder object accumulates configuration through method calls and produces the final object at the end. For example, building an HTTP request: new RequestBuilder().url("...").method("POST").body(json).timeout(30).build(). This is very common in Java (e.g., StringBuilder, Retrofit's builder) and Kotlin's DSL builders.