Ever stare at your own code from 6 months ago and wonder why it’s so hard to change anything without breaking something else? I kept running into the same structural problems across projects until I realized most of them had well-known solutions — design patterns.
I put this series together from various sources (mostly Viblo articles) to solidify my own understanding. All examples are in TypeScript. Out of the 250+ patterns the Gang of Four catalogued, about 26 cover most real-world situations. The core idea is simple: separate the parts that are hard to extend into independent objects, then restructure them so future changes don’t cascade.
Note: Design Patterns are not algorithms, and they’re not components.
| Creational | Structural | Behavioral |
|---|---|---|
| Singleton | Adapter/ Wrapper | Chain of Responsibility |
| Factory | Bridge | Command |
| Method Factory | Composite | Mediator |
| Abstract Factory | Decorator | Memento |
| Builder | Facade | Observer |
| Object Pool | Proxy | Strategy |
| Prototype | Flyweight | Visitor |
| Dependency Injection | Delegation | State |
| Entity-Attribute-Value (EAV) | Repository |
Patterns I left out:
- Template Method: Basically just inheritance when your code is already clean. Nothing special.
- Null Object: Since child classes don’t just implement the parent’s skeleton but also add their own methods, you’d need separate null objects for each class type. Makes extending harder, not easier.