Part 6
3 chapters
Creating Objects Under Control
Factory Method and Abstract Factory, Builder with dataclasses and Prototype, and Singleton as a module, a Borg, or a metaclass.
Chapter 16
Factory Method and Abstract Factory
Factory Method dissolves into a class or a Self classmethod in a Callable slot, while Abstract Factory survives as one frozen kit per carrier family, with mypy tying only the products that pass values to each other.
Chapter 17
Builder, dataclasses, and Prototype
Builder and Prototype dissolve into a frozen keyword-only dataclass that validates once and replace for copies, with the field types deciding what a shallow copy shares.
Chapter 18
Singleton: module, Borg, and metaclass
Singleton needs disambiguating: the default is a module built at import time or on first use, with a parameter for tests and a double-checked lock for loads that need run-time input.