The abstract factory creational pattern allows you to organize different sets of classes that work together so they get created together. This lets you change from one group of classes to another by configuring a different abstract factory.

You first need to create an interface that’ll be common for each type of factory. This interface will have create methods for each object that you want created by a factory. These individual create methods are factory methods and are implemented by the concrete factory instance. What makes this pattern different from just the factory pattern is this interface that brings together many different types that all need to work together. By switching to a new factory, other code can start creating different instance types that are designed to work well together as this new factory determines.

Each create method will need to return an interface or base class because the actual type that’s returned will depend on what concrete type the factory decides to create. Since there are many different factories each trying to return different types for the same create method, we need a common interface for each of these.

The episode also describes some problems you might encounter with this pattern and some suggestions for modifying the basic pattern to fit your needs.