Circuit Breaker

A Circuit Breaker’s trip trigger and recovery strategy must be designed together. Trip without recovery cuts the dependency permanently; recovery without a trip basis becomes meaningless cycling.

February 15, 2025 · 7 min read

Observer

Observer cuts coupling through a one-to-many relationship that notifies subscribers of state changes. The Subject just notifies, unaware of who listens. EventEmitter, RxJS, and event-driven architecture all extend from here. It differs from broker-mediated pub/sub.

March 17, 2024 · 3 min read

Strategy

Strategy encapsulates a family of algorithms behind a single interface and swaps them at runtime. It extends by adding a strategy instead of editing an if/switch. In languages with first-class functions, a separate Strategy class collapses into a single function.

March 3, 2024 · 4 min read

Facade

Facade provides a simple entry point to a complex subsystem, cutting the coupling between the client and the internals. A service layer or a library SDK is effectively a Facade. It differs from Adapter (interface conversion) and Mediator (two-way coordination).

February 25, 2024 · 3 min read

Decorator

Decorator replaces the subclass explosion of inheritance with composition. It stacks wrappers that keep the same interface to add behavior at runtime. java.io, Python function decorators, and web middleware chains are all variations on the same intent.

February 18, 2024 · 4 min read

Builder

Builder is the answer when three limits of constructors meet at once — many parameters, some optional, and step-wise validation. With fewer than all three, simpler tools suffice. When the language provides rich named/default parameters, the need for Builder shrinks as well.

February 11, 2024 · 5 min read

Factory

Factory’s shared intent is separating creation from use. The three variants — Factory Method, Abstract Factory, and Static Factory Method — split creation differently and suit different conditions. Static Factory Method is the variant most often encountered in practice, and DI containers absorb part of Factory’s explicit role.

February 4, 2024 · 5 min read

Singleton

Singleton is one of the simplest patterns but the canonical anti-pattern debate. The decision to bundle single-instance guarantee with global access into one pattern causes tight coupling and test difficulty. DI is the general alternative that separates the two intents.

January 28, 2024 · 5 min read

Dependency Injection — The Hierarchy of DIP, IoC, and DI

DIP (principle), IoC (pattern), and DI (technique) sit at different levels of abstraction. The hierarchy must be clear before framework features and design principles can be told apart.

January 25, 2024 · 6 min read