O'Reilly logo

Learning Python Design Patterns by Gennadiy Zlobin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Abstract Factory

If the goal of the Factory Method is to move instances creating to subclasses, the goal of an abstract factory is to create families of related objects without depending on their specific classes. As shown in the following diagram, every factory derived from the AbstractFactory interface has methods to create instances of two interfaces, AbstractProduct and AnotherAbstractProduct. The idea is that the created objects should have the same interface, whereas, the created concrete objects are different for every factory. So, if you want to get a different behavior, you can change the factory in runtime and get a full set of different objects.

Abstract Factory is used when you need to create a family of objects that do some work together. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required