
Stop Hardcoding Object Creation: Factory Pattern for Real Systems
📘 Design Patterns for Builders — Part 2 In Part 1, we used Strategy to remove if-else from business logic. Now we fix the next problem: who decides which strategy to create—and how? ⚡ TL;DR Don’t scatter SomeClass() across your codebase Centralize creation behind a factory Separate usage from creation Evolve toward registry/DI as systems grow The Problem (Picking Up From Strategy) After introducing Strategy, you often end up here: ...
