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

Horizontal vs Vertical Slicing

The difference between splitting code by technical layers (horizontal) and by features or domains (vertical). Trade-offs and selection criteria for each approach.

March 10, 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

Layered Architecture and Dependency Inversion

Layered architecture separates code into horizontal layers by technical responsibility. A summary of the four-layer structure, dependency direction rules, and how DIP decouples layers.

February 23, 2024 · 4 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