The Abstract Factory Design Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. It keeps objects from different families from being mixed accidentally. section 9.0 section 9.4
Use the pattern when one domain contains coordinated product families. In the athletics example, varsity and intramural sports require different combinations of player and venue objects. section 9.2 section 9.3
A practical implementation separates family selection from product construction:
- Implement VarsityFactory and IntramuralFactory so each creates only products from its own family. section 9.2.2
- Let VarsityDept and IntramuralDept select their corresponding factories while remaining unaware of construction details. section 9.2.2
Athletics departments and sport families
VarsityFactory can create VarsityBaseballPlayers or VarsityFootballPlayers and a Stadium; IntramuralFactory can create intramural player strategies and an OpenField. VarsityBaseball and IntramuralFootball then retain their family category while Sport obtains its collaborators through the selected factory.
Figure 9.4 This version of the application is modeled from the Abstract Factory Design Pattern. Interface ProvisionsFactory is the abstract factory whose implementor classes are used by the Sport subclasses. Implementor class VarsityFactory creates the varsity family of player and venue objects, and therefore, VarsityDept uses VarsityFactory. Implementor class IntramuralFactory creates the intramural family of player and venue objects, and therefore, IntramuralDept uses IntramuralFactory. The grayed-out portions of the diagram have not changed logically from figure 9.2.
Use the architecture diagram to trace ProvisionsFactory, its concrete factories, department clients, and the player and venue product families. section 9.2.2
Unlike Factory Method, which creates one object with subclass-selected variants, Abstract Factory creates a coordinated family and reduces accidental cross-family combinations. section 9.3


