Builder pattern

[1] The builder design pattern solves problems like:[2] Creating and assembling the parts of a complex object directly within a class is inflexible.

The intent of the builder design pattern is to separate the construction of a complex object from its representation.

[1] Advantages of the builder pattern include:[3] Disadvantages of the builder pattern include:[3] In the above UML class diagram, the Director class doesn't create and assemble the ProductA1 and ProductB1 objects directly.

Instead, the Director refers to the Builder interface for building (creating and assembling) the parts of a complex object, which makes the Director independent of which concrete classes are instantiated (which representation is created).

The Builder1 class implements the Builder interface by creating and assembling the ProductA1 and ProductB1 objects.

A sample UML class and sequence diagram for the builder design pattern. [ 4 ]
Builder Structure
Builder Structure