Factory Method in Python
Written by a romantic on January 11, 2017
Factory Method is one of many design patterns, probably the most used in languages like Java or C++.
The basic idea is to have a Parent class and some Children classes. The Parent class (aka, The Factory) contains all the methods common to the Children classes plus a @classmethod
method that is used to decide which specific Children class to instantiate.
Here an example:
Which would output:
This is it!