Design of the Day : Abstract Factory Pattern
Date: 06/25/05
(Algorithms) Keywords: software
PREFACE:
By popular demand, here is the first of the Design of the Day series.
INTENT:
1) Much like "Word of the Day" only related to Algorithms, Advanced Datastructures, or Patterns.
2) Expand knowledge of useful design principles, much like expanding your vocabulary.
FINALLY:
I belive it would be mutually beneficial to evaluate wikipedia definitions and make corrections/additions when approved unanimously here in this community.
//---
Without further Ado: The Abstract Factory (wikipedia).
Summary:
"Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. In normal usage, the client software would create a concrete implementation of the abstract factory and then use the generic interfaces to create the concrete objects that are part of the theme. The client does not know (nor care) about which concrete objects it gets from each of these internal factories since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from its general usage"
Example:
"An example of this would be an abstract factory class documentCreator that provides interfaces to create a number of products (eg. createLetter() and createResume()). The system would have any number of derived concrete versions of the documentCreator class like fancyDocumentCreator or modernDocumentCreator, each with a different implementation of createLetter() and createResume() that would create a corresponding object like fancyLetter or modernResume."
UML Diagram
Source: http://www.livejournal.com/community/algorithms/57445.html