🧱Abstract Factory

Abstract Factory is a creational design pattern, which solves the problem of creating entire product families without specifying their concrete classes.

triangle-exclamation

Usage examples

The Abstract Factory pattern is pretty common in C++ code. Many frameworks and libraries use it to provide a way to extend and customize their standard components.

Identification

The pattern is easy to recognize by methods, which return a factory object. Then, the factory is used for creating specific sub-components.

Pros & Cons

circle-check
circle-check
circle-check
circle-check
triangle-exclamation

Graphic Visual

Flow of Abstract Factory
Settimana Enigmistica Style

Example

This example illustrates the structure of the Abstract Factory design pattern. It focuses on answering these questions:

  • What classes does it consist of?

  • What roles do these classes play?

  • In what way the elements of the pattern are related?

Conceptual Example

main.cpp

output.txt

Last updated