Context:

  1. Creating objects by two criteria: Base type (Known to the application) and environment (preconfigured). (E.g. creating GUI controls, given control type and knowing the GUI system being emulated).
  2. An array of factory methods with the same implementation criterion. (Same example as above, where the need for each control type has aroused on a separate occasion.)

Challenge:

To encapsulate the decisions in a single object.

Skill:

Participants:

Abstract Factory:

A Singleton. The capability to create discrete products for a pre-configured environment.

Concrete Factory:

A set of methods for creating discrete products for a concrete environment.

(Some) Abstract Product:

(A passive entity.) One of the Abstract Factory's declared Product types.

(Some) Concrete Product:

(A passive entity.) The implementation of one of the Abstract Factory's declared Product types for a particular environment.

Signature:

Abstract factory responds to creation messages explicitly named after each conceptual product type. Each concrete factory implements this interface for a concrete environment. The products are arranged in respective discrete type families where environment implementations derive from product.

Used patterns and idioms:

singleton.

Source:

GOF.

Scope:

General.