The Abstract Factory Pattern is defined in Design Patterns, Creational catagory. From Design Patterns:

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

This pattern consists of an Abstract Factory class, which defines one or more methods to create objects (see Factory Method Pattern). Each of these methods can be abstract, defined in one or more concrete subclasses of the Abstract Factory.

Using the X Windowing System as an example, an application could support multiple GUI toolkits. An abstract GuiToolkit class, with methods for creating Windows, Buttons, etc, could have concrete subclasses MotifGuiToolkit, GtkGuiToolkit, and QtGuiToolkit. The createButton method in each class would return a Button object, itself an abstract class with MotifButton, GtkButton, and QtButton as concrete subclasses.

This pattern makes exchanging product families easier. A new family can be introduced by subclassing the Abstract Family. It also encourages the families to adopt consistant interfaces.

Log in or registerto write something here or to contact authors.