Creational Design Pattern: Abstract Factory Pattern

Level : Intermediate
Mentor: Shailendra Chauhan
Duration : 00:01:00

Abstract Factory Pattern

Abstract Factory Patterns function as a super-factory, generating other factories. The pattern is also known as a Factory of factories. In the Abstract Factory pattern, an interface is in charge of generating a factory of related or dependent objects without specifying their specific classes.

Abstract Factory Pattern with UML diagram

The UML class diagram above defines the following classes, interfaces, and objects:

  • AbstractFactory: This interface is used to generate an abstract product.
  • ConcreteFactory: This class uses the AbstractFactory interface to build concrete items.
  • AbstractProduct: This interface declares the type of product.
  • ConcreteProduct: This is a class that uses the AbstractProduct interface to generate a product.
  • Client: This class uses the AbstractFactory and AbstractProduct interfaces to build a family of linked objects.

When should we use the Abstract Factory pattern?

The abstract factory pattern is useful in the following cases:

  • Create a collection of related or dependent things that must be used together.
  • Configure the system to function with multiple product families.
  • The production of items should be independent of the system.
  • Concrete classes should be isolated from clients.
Self-paced Membership
  • 24+ Video Courses
  • 850+ Hands-On Labs
  • 500+ Quick Notes
  • 225+ Skill Tests
  • 120+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this