1. Simple factory:
The factory class in a simple factory contains logical judgments that can be dynamically created based on the client's choice, removing the client's reliance on the specific product. Note that simple factories violate the principle of opening and closing in design mode, so simple factories are not design patterns.
Constitute:
A specific factory class that contains logical judgments;
An abstract product class that can derive multiple specific product classes.
2. Factory Method Mode:
Define an abstract factory class, which is responsible for developing specifications in this abstract factory class, putting the actual creation of the product into the subclass. The Core factory class is no longer responsible for the creation of the product, so that the core class becomes an abstract factory role, only responsible for the specific factory subclass must implement the interface, relative to the simple factory can make the system without modification of the factory, the introduction of new products. Each specific factory class can only create an instance of a specific product class.
Constitute:
An abstract product class that can derive a number of specific product classes.
An abstract factory class that can derive a number of specific factory classes.
3. Abstract Factory mode
Abstract Factory mode refers to a factory pattern that is used when there are multiple abstract roles. Abstract Factory mode provides the client with an interface that enables the client to create product objects in multiple product families without having to specify the product's specific circumstances. Abstract factories have multiple abstract product classes relative to the factory method pattern, and each specific factory class can create instances of several specific product classes. Rather than as a factory method, a factory can only create one product.
Constitute:
Multiple abstract product classes, each abstract product class can derive multiple specific product classes.
An abstract factory class that can derive a number of specific factory classes.
Simple factory, abstract factory, factory method difference