Abstract Factory

Abstract Factory is a creational design pattern. Abstract factory design pattern is used when you need to provide a common theme or template to related objects without specifying concrete classes. It is similar to Factory design pattern with an additional layer of abstraction.

Abstract Factory Scenario

Abstract Factory design pattern is used when a general pattern is followed. When we have to create objects with a common theme, template or properties, Abstract Factory design pattern can be used. It allows us to create objects which follow a common class.

In short, when we want to create objects related to a common family, we use abstract factory design pattern.

Abstract Factory Example

There are many scenarios where you can apply Abstract Factory. In this example, we will consider a parent category as Car. There are different categories of cars including Cab, Sedan, SUV, etc.

Leave a Reply

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