Abstract Factory _ Notes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.