What is the FACTORY METHOD PATTERN in Python?

preview_player
Показать описание
This video shows why and when to use a the factory method design pattern and how it is different from a factory. It is the second video in a 3-part video series: Factories

C H A P T E R S
1:00 The factory method pattern puts the class instantiation in subclasses
1:30 In a dynamic language like Python, the abstract method is not needed
1:53 Let subclasses decide which class to instantiate
3:33 The factory method pattern does not help to prevent switching on types
3:56 open-closed principle violation
4:18 The benefit of the factory method pattern is abstraction
5:27 The factory method pattern helps to put code where it belongs

M Y O N L I N E T R A I N I N G

#factorymethod #programming #python
Рекомендации по теме
Комментарии
Автор

Is the ImporterFactory @1:40 really correct? In python, the linter (Pylance, python 3.11.3) reports:

Cannot access member "create_importer" for type "ImporterFactory" Member "create_importer" is
(function) create_importer: Unknown

The end code still works.

machinimaaquinix