Builder Pattern
Separates the construction of a complex object from its representation, as that the same construction process can create different representations.
When to use
- The algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled. 
- The construction process must allow different representations for the object that's constructed. 
- You want to get rid of a "telescopic constructor". 
Structure

- Builder: defines the interface for creating parts of a product object. 
- ConcreteBuilder: constructs and assembles parts of the product by implementing the Builder interface, also keeps track of the representation it creates, and provides an interface to retrieve it. 
- Director: constructs an object using the builder interface. 
- Product: represents the complex object under construction. 
Examples
Source Code
UML
// TODO
You can find the tests here.
Last updated
Was this helpful?