Builder
Kotlin takes most of this pattern away. Named and default arguments handle the ordinary case; what survives is step-by-step validation, type-safe builder DSLs, and Java interop. Worth studying precisely to see where the language stops helping.
Structure
classDiagram
class Builder {
<<interface>>
+setPartA(v) Builder
+setPartB(v) Builder
+build() Product
}
class ConcreteBuilder
class Director {
+construct(b) Product
}
class Product
Builder <|.. ConcreteBuilder
Director o--> Builder
ConcreteBuilder ..> Product : builds
Telling It Apart
Patterns whose structure looks the same but whose intent does not. See the Confusing Pairs reference.
- Abstract Factory — Create whole families of related objects that must be used together, without naming their concrete classes.