Design pattern-- summary of factory pattern
In the design pattern, the factory pattern can also be subdivided into simple factory pattern, factory method pattern and abstract factory pattern. In the past, the concepts of these three design patterns were not very clear, so here is a summary:
1. Simple factory model
An abstract product derives multiple concrete products; users can create specific products according to some properties of the product according to a specific factory. Factories and specific products are one-to-many.
two。 Factory method model
An abstract product derives from a specific product; an abstract factory derives from a specific factory; and the user creates a concrete product based on the specific factory. Specific factories and specific products are one-to-one.
3. Abstract factory pattern
An abstract product derives from a specific product; an abstract factory derives from a specific factory; and the user creates a concrete product based on the specific factory and some attributes of the product. Abstract factory patterns can be seen as a combination of simple factory patterns and factory method patterns!
Follow-up to the code sample!