Java design mode ------ builder mode, java design mode ------
Builder mode separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.
Class Diagram
Description
Builder: defines a Builder abstract class to standardize the construction of each component of a product object. This interface specifies the parts of the object to be created, and does not involve the creation of specific object parts.
ConcreteBuilder: inherits the Builder to create specific parts of an object based on different business logic. After the construction process is complete, provide the product instance.
Director: Call a specific builder to create all parts of an object. The supervisor does not involve information about a specific product. Instead, he is only responsible for ensuring that all parts of the object are completely created or created in a certain order.
Product: the object to be created.
The builder mode only has one "ctor class" role more than the factory mode.
Application scenarios
Taking car production as an example, the builder is responsible for producing all parts of the car, and the conductor is responsible for directing the builder to assemble the car according to the process.