Design mode only abstract Factory pattern

Source: Internet
Author: User

Abstract Factory mode can be simply understood as an abstraction of the factory pattern, which is a common and abstract product of multiple factory that defines the unified interface for objects created by factory method. Concreteproduct a specific class to implement the product interface. Creator is generally an abstract class that declares several FactoryMethod (methods) that create objects of type product. Because it can "produce" objects, it is called FactoryMethod. Creator may also have a method to create a default specific object. Concretecreator overloads factory method to create a specific instance of a concreteproduct. Each subclass of an abstract class is a factory that can build products of different requirements, such as the BMW factory and the Mercedes-Benz plant.

In the abstract factory model, each concretecreator only produces a specific product, such as BMW's production workshop, only the production of BMW, but not the production of Mercedes-Benz cars, the same Mercedes-Benz production plant can only produce Mercedes-Benz cars and not the production of BMW cars, Both the BMW and Mercedes-Benz production plants use the same tectonic model, that is, they are inherited to achieve the creator, for product, I just know the need for a Mercedes, but do not care about the car in which workshop production. 2009-12-27


The difference between the Factory pattern and the abstract Factory pattern can be compared with the two production plants of BMW and Mercedes. In factory pattern, the user as long as I request from the Mercedes-Benz Workshop or BMW workshop to provide a product, that is, the product type has been specified in the user. In the abstract Factory pattern, the user does not specify that the product I want is coming out of a BMW or Mercedes-Benz workshop.

Application Example: A font in a PDF file that displays the specified font if the specified font type exists, otherwise the system default font is called. 2012-3-13

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.