The Factory method versus Abstract Factory method

Now that you have learned the Factory method and Abstract Factory method, let's see the comparison of the two:

Factory method

Abstract Factory method

This exposes a method to the client to create the objects

Abstract Factory method contains one or more factory methods to create a family of related objects

This uses inheritance and subclasses to decide which object to create

This uses composition to delegate responsibility to create objects of another class

The factory method is used to create one product

Abstract Factory method is about creating families of related products

Get Learning Python Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.