Tuesday, January 1, 2008

Abstract Factory Pattern


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

Description:
The Abstract Factory pattern defines an abstract class that determines the
appropriate concrete class to instantiate to create a set of concrete classes that
implement a standard interface. The client interacts only with the interfaces and the
Abstract Factory class. The client is completely shielded from the concrete classes.
The Abstract Factory pattern is similar to the Factory Method pattern, except that it
creates families of related objects and can be considered as a factory of factories.


Benefits:
• Isolates concrete classes.
• Makes exchanging product families easy.
• Promotes consistency among products.

When to use?
You can use the Abstract Factory pattern when:
• The system should be independent of how its products are created,
composed, and represented.
• The system should be configured with one of the multiple families of
products.
• A family of related product objects is designed to be used together and
you need to enforce this constraint.
• You want to provide a class library of products and you want to reveal just
their interfaces, not their implementations.

No comments: