Intent
It provide an interface for creating a group of objects without specifying their concrete classes.
Where to use & benefits
we can use this pattern whenever we want
- a system should be independent of how its products are created, composed, and represented.
- a system should be configured with one of multiple families of products.
- to provide a class library of products, and want to reveal just their interfaces, not their implementations.
Structure

Participants
AbstractFactory (IShapeAbstractFactory)
declares an interface for operations that create abstract product objects
ConcreteFactory (RedRectangleFactory, (BlueCircleFactory)
implements the operations to create concrete product objects
AbstractProduct (IShapeFactory, IColorFactory)
declares an interface for a type of product object.
ConcreteProduct (ShapeFactory, ColorFactory)
- defines a product object to be created by the corresponding concrete factory.
- implements the AbstractProduct interface.
uses only interfaces declared by AbstractFactory and AbstractProduct classes.
Example
In the demonstration application, ColorShapeFactory class uses ShapeFactory and ColorFactory classes to create the colored shape objects.
Class Diagram
