First, the definition
- Generator pattern: Separates the construction of a complex object from its performance, allowing the same process to create different manifestations.
- The builder pattern includes two important roles: Mentor and generator
- The instructor knows how to build the product without knowing that certain information is missing.
Second, the use of generators
- You need to create complex objects that involve various parts. The algorithm that creates the object should be independent of the Assembly method of the part.
- The build process needs to build objects in different ways
Iii. Comparison of generators and abstract factories
|
Generator |
Abstract Factory |
| 1 |
Building Complex objects |
Building complex or abstract objects |
| 2 |
Building objects in multiple steps |
Building objects in a single step |
| 3 |
Building objects in multiple ways |
Building objects in a single way |
| 4 |
Return the product in the final step of the build process |
Return to Product now |
| 5 |
Focus on a specific product |
Emphasize a set of products |
iOS design mode-generator mode