Role:
The construction of a complex object is separated from its representation, allowing the same build process to create different representations.
UML Structure diagram:
Applies to the following situations:
1 The algorithms for creating complex objects should be independent of the components of the object and the way they are assembled.
2 when the construction process must allow the constructed object to have a different representation.
Abstract base class:
1 Builder: This base class is an abstraction of all the process of creating objects, providing interface functions to build different components
Interface:
1) BUILDER::BUILDPARTA,BUILDER::BUILDPARTB: It is the construction function interface of the different parts of an object, the Builder derived class to implement concretely.
Another function to note is the Director::construct function, which completes the construction of the object by calling the two interface functions above--that is, the process of assembling the different parts is consistent (the same construct function of the call), But different builds have different representations (depending on the actual type of builder to determine how to build, that is, polymorphism)
Analytical:
The builder model is based on a situation where: an object may have different components, and the different objects in these sections will have different representations, but the way in which the parts are assembled is consistent. For example, a bicycle is made up of wheel seats and so on (a different part of an object), Different brands are produced differently (different build styles). Although different brands build bicycles differently, the process is the same (oh, have you ever seen a wheel in a car seat?).
In other words, the director::construct function is fixed by the assembly of the various components, and specifically how the components of the assembly by the builder derived class implementation.