The Abstract Factory Pattern adds another layer of abstraction over the Factory Pattern. It has an Abstract Factory Interface which is implemented by several Factory classes. A Super Factory decides which Factory should be used based on the requirement. Abstract Factory Pattern is one the creational design patterns.
Participants
- AbstractFactory
An interface which for creating AbstractProduct objects. - ConcreteFactory
Implements AbstractFactory and creates ConcreteProduct objects. - AbstractProduct
An interface for type of products. - ConcreteProduct
Implements AbstractProduct object. Here is where the actual product code is defined. - Client
Uses methods provided by AbstractFactory and AbstractProduct interfaces to create objects.
UML Diagram
As you can see in the diagram, There is an AbstractFactory interface which is implemented by 2 factory classes. Client doesn't access the concrete factory classes directly, instead uses the methods provided by AbstractFactory interface.
Comments
Post a Comment