The concept of builder model pattern
The builder pattern separates the construction of a complex object from its representation, allowing the same build process to create different representations. That is to say, if we use the builder model, then the user needs to specify the type that needs to be built to get them, and the process and details of the construction need not be known. The builder model is actually a conductor, a builder, and a client who uses the command to invoke the results of a specific builder's work.
The builder model is used primarily to "step through a complex object", where "step-by" is a stable algorithm, while the parts of complex objects often change.
Popular said: Is a white rich United States need to build a villa, and then directly to find a contractor, the contractor to find workers to build the villa. This one Bai Fumi not directly to a worker's to find. and the contractor know Bai Fumi needs, know where to find workers, workers can work, the middle save Bai Fumi and the cost of communication between workers, Bai Fumi also do not need to know how to build concrete house, finally can get the room.
Builder Pattern Structure diagram
Ii. role and considerations of the builder model
Mode function:
1. step-by-Step to create a complex object
2. Decoupling encapsulation process and concrete creation component
3. No need to care about how components are assembled
Precautions:
1. Must be a stable algorithm to support
2. Processing technology is exposed--Bai Fumi don't care how to build a house, but you can always go to see how the house is built.
Third, the builder pattern code and the actual combat summary