December 2021
Intermediate to advanced
352 pages
10h
English
All creational patterns deal with ways to create instances of objects. This is important because your program should not depend on how objects are created and arranged. In Python, of course, the simplest way to create an instance of an object is by creating a variable of that class type.
fred = Fred() # instance of Fred class
However, this really amounts to hard coding, depending on how you create the object within your program. In many cases, the exact nature of the object that is created could vary with the needs of the program. Abstracting the creation process into a special “creator” class can make your program more flexible and general.
The Factory method provides a simple decision-making ...
Read now
Unlock full access