The Builder design pattern provides a solution:
Encapsulate creating and assembling the parts of a complex object
in a separate Builder object.
A class
delegates object creation
to a Builder object
instead of instantiating concrete classes directly.
Describing the Builder
design in more detail is the theme of the following sections.
See Applicability section for all problems
Builder can solve.
Director).
Builder objects:
Builder | buildPartA(),buildPartB(),…).
Builder1,…)
that implement the interface.
Director)
delegates the responsibility for
creating and assembling the parts of a complex object
to a Builder object
(builder.buildPartA(),builder.buildPartB(),…).
Builder objects
to create different representations of a complex object.