Abstract factory pattern

We have just learned how to create and use a simple factory in a program. Let's go a little further and study a formal pattern known as the abstract factory pattern.

Imagine we have a master factory and some follower factories. Further assume that each follower factory is responsible for producing its own trademark products (objects). The follower factories are related in some sense. They create products that share a common theme. For example, each follower factory produces its own version of tomato ketchup. The factories have their own ordering form for their product.

The customers have a hard time in keeping up with so many forms for ordering a tomato ketchup. For example, one factory says you should call it MyRedTomatoKetchup, ...

Get Learning Python Application Development now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.