Abstract factory
This design pattern creates an interface to create a family of interrelated objects without specifying their concrete class. It is similar to a superfactory. Its advantage is that we can add further variants, and clients will not have to worry further about the interface or actual classes for the new variants. It is helpful in supporting various platforms, windowing systems, data types, and so on. In the following example, the Animal class is the interface that the client will know about for any animal instance. AnimalFactory is the abstract factory that DogFactory and CatFactory implement. Now, on the runtime by user input, or configuration file, or runtime environment check, we can decide whether we will have all Dog or Cat instances. It is very convenient to add a new class implementation, as follows:
import os
import abc
import six
class Animal(six.with_metaclass(abc.ABCMeta, object)):
""" clients only need to know this interface for animals"""
@abc.abstractmethod...