Abstract Factory:
Definition: Provides an interface for creating a set of related or interdependent objects without specifying their specific classes.
Type: Create class mode
Class Diagram:
Calling the class client
Factory Interface Ifactory Product interface iproduct
+createproduct () +productmethod ()
Factory realizes product Factory
The difference between abstract Factory mode and factory method mode
Abstract Factory mode is an upgraded version of the factory method pattern that is used to create a set of related or interdependent objects. He and the factory method model
The difference is that the factory method model is for a product hierarchy, whereas the abstract factory model is for multiple product hierarchies. In programming,
Typically a product structure is represented as an interface or abstract class, that is, all the factory method schemas provide are derived from the same interface or
Abstract class, and the products provided by the abstract factory schema are derived from different interfaces or abstract classes.
In the abstract factory model, there is a product family concept: the so-called product family, refers to the different products in the hierarchical structure of the function-related products of the family.
The abstract factory model provides a range of products to form a product family, while the factory approach provides a range of products that become a hierarchical structure.
Understand the concept of hierarchy and product family, understand the difference between the factory method pattern and the abstract factory model, if the product of the factory does not belong to the same
Hierarchical structure, which is the factory method mode, is the abstract Factory mode if the factory product comes from multiple hierarchical structures.
Summarize:
Simple factory:
1. Abstract Products
2. Specific Products
3. Simple Factory
Factory mode:
1. Abstract Products
2. Specific Products
3. Abstract Factory
4. Specific Factory
Abstract Factory mode: (1. There are multiple product families in the system, and the system may only consume one of the products at a time 2. Products that belong to the same product family are used. There is a product family concept: the so-called product family refers to the family of products that are related to functions in different product hierarchy structures
1. Abstract Products
2. Specific Products
3. Abstract Factory
4. Specific Factory
Reference:http://blog.csdn.net/zhengzhb/article/details/7359385
Http://www.cnblogs.com/zhangchenliang/p/3700820.html
The difference between Factory mode and policy mode:
The difference between a factory pattern and a policy pattern is that the instantiation of an object is different, and for the Factory mode, the instantiated object is placed on the service side, which is placed in the factory class;
While the operation of the policy mode instantiation object is on the client side, the "sales department" of the server is only responsible for passing the object and performing specific actions in the environment of the server.
The factory model requires that the sales department on the service side is sensitive enough, and the strategy model has been packaged for the strategy, so his sales department is a fool, requiring the customer to provide enough parameters to differentiate which strategy to use, which is best done by an instance of the strategy.
(go) Abstract Factory _ Notes