Builder pattern (Builder)



 GOF intent: to separate the construction of a complex object (the Director ) from its representation (the builder), so that the same construction process ( defined by the Director ) can create different representations (the builder is assembling) . (separation of build and presentation)

 

Role:

1 builder: For the builder, provide the interface buildPart() to build part of the product, and the interface geResult() to obtain the construction result.

2 ConcreteBuilder: Concrete builder, there can be multiple concrete builders. The appearance of products built by different builders is different.

3 Director, commander: The commander unifies the construction process. Different builders passed on to the commander will create products with different appearances.

4 Product: Represents a complex object that is constructed.

 

Implementation points: the director defines the construction process of the product, the builder creates parts and assembles the product, and provides an interface for returning the product.

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944597&siteId=291194637