Robots Atlas>ROBOTS ATLAS

Python โ€” From Basics to Advanced ยท Design Patterns in Python

Factory Method, Abstract Factory, Builder, Registry

Design Patterns in Python

Introduction

Four creational patterns, one goal: decouple the CLIENT from the decision "which concrete class do I instantiate". Factory Method (and its simpler sibling โ€” simple factory / classmethod factory) picks the object type. Abstract Factory does that for a whole family of objects. Builder solves the 15-arg-constructor problem with a fluent API. Registry is a Pythonic plugin system based on a dict. In Python many of these collapse into a simple class dict, @dataclass, or __init_subclass__ โ€” no GoF ceremony required.