Abstract Factory Pattern

-> In Abstract Factory Pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes. Each generated factory can give the objects as per the Factory Pattern.
-> Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories.

Implementation

1) Create an interface for Shapes

2) Create concrete classes implementing the same interface.

3) Create an interface for Colors

4) Create concrete classes implementing IColor Interface.

5) Create an Abstract class to get factories for Color and Shape Objects.

6) Create Factory classes extending AbstractFactory to generate object of concrete class based on given information.

7) Create a Factory generator/producer class to get factories by passing an information such as Shape or Color.

8) Use the FactoryProducer to get AbstractFactory in order to get factories of concrete classes by passing an information such as type.

 

Leave a Reply

Your email address will not be published. Required fields are marked *