Design Pattern Abstract Factory Pattern - Design Patterns

What is Design Pattern Abstract Factory Pattern?

Abstract Factory patterns effort about a super-factory which creates other factories. This factory is also called as factory of factories. This kind of design pattern comes below creational pattern as this pattern provides single of the best ways to create an entity.

In Abstract Factory pattern a line is accountable for creating a factory of related objects without openly specifies their classes. Each generated factory can give the substance as per the Factory pattern.


We are available to create a form and Colour interfaces and real classes implementing these interfaces. We make an abstract factory class summary Factory as after that step. Factory classes Shape Factory and ColorFactoryare define where each factory extends Abstract Factory. A factory creator/generator class Factory creator is created.

AbstractFactoryPatternDemo, our presentation class uses Factory maker to get an Abstract Factory object. It will pass information (CIRCLE / RECTANGLE / SQUARE for Shape) to Abstract Factory to get the form of entity it needs. It also passes in order (RED / GREEN / BLUE for Colour) to Abstract Factory to get the kind of object it requirements.

Step 1

Make an interface for Shapes.

Step 2

Create existing classes implementing the similar interface.

Step 3

Create an interface for Colours.


Generate concrete classes implement the same interface.

Step 5

Generate an Abstract class to get factories for Colour and Shape Objects.

Step 6

Construct Factory classes extending Abstract Factory to generate entity of real class based on known in order.

Step 7

Create a works creator/producer class to get factories by passing in sequence such as form or Colour.

Step 8

Use the Factory maker to get Abstract Factory in direct to get factories of real classes by transient information such as form.

Step 9

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics