Design Patterns

Object-oriented, architectural, distributed-systems, and functional pattern notes with pragmatic implementation context.

25
70 min
24
0

Ordered notes

Adapter Pattern

Adapter allows classes with incompatible interfaces to work together by converting the interface of one class into an interface expected by the client. It acts as a wrapper that sits between two unrelated components,...

Bridge Pattern

The Bridge pattern decouples an abstraction from its implementation, so the two can vary independently. It achieves this by using composition: an abstraction class holds a reference to an implementor interface, and...

Builder Pattern

The Builder pattern separates the construction of a complex object from its representation, allowing step by step construction and the ability to vary the product’s internal representation. It is useful when an object...

Chain of Responsibility Pattern

Chain of Responsibility passes a request along a chain of handler objects until one of them handles it. Each handler in the chain either handles the request or passes it to the next handler. This pattern decouples...

Command Pattern

Command turns a request or operation into a stand alone object that can be stored, passed around, and invoked later. In essence, it encapsulates an action as an object. This decouples the object that invokes the...

Composite Pattern

Composite pattern composes objects into tree structures to represent part whole hierarchies. It lets clients treat individual objects and compositions of objects uniformly. In other words, a composite allows a group of...

CQRS (Command Query Responsibility Segregation)

CQRS is an architectural pattern that separates read operations from write operations of a data store into different models, commands and queries. The term comes from Command Query Responsibility Segregation . In a...

Decorator Pattern

Decorator attaches new responsibilities or behaviors to an object dynamically, without altering its structure. It provides a flexible alternative to subclassing for extending functionality. A decorator wraps an object...

Dependency Injection (and Inversion of Control)

While not a “pattern” in the GoF sense, Dependency Injection (DI) is an essential design principle/pattern for modern software construction. It is a technique where an object’s dependencies (its collaborators or...

Design patterns

Design patterns Adapter Pattern Bridge Pattern Builder Pattern Chain of Responsibility Pattern Command Pattern Composite Pattern CQRS (Command Query Responsibility Segregation) Decorator Pattern Dependency Injection...

Event Sourcing

Event Sourcing is an architectural pattern in which state changes are stored as a sequence of events, rather than storing just the current state. Whenever something changes, an event is recorded (typically in an append...

Facade Pattern

Facade provides a unified, simplified interface to a complex subsystem of classes. It hides the complexity of multiple interrelated classes behind a single wrapper interface. This makes the subsystem easier to use for...

Factory Method and Abstract Factory

Factory Method is a creational pattern that defines an interface for creating an object but lets subclasses decide which class to instantiate. Instead of calling a constructor directly, the client calls a factory...

Microkernel (Plugin) Architecture

Microkernel architecture (also known as plugin architecture ) is a pattern where a core system provides minimal functionality, and additional features are implemented as independent plug in modules that extend the...

Microservices Architecture

Microservices architecture is an architectural style where an application is structured as a collection of small, independently deployable services that communicate over a network (often via HTTP/REST or messaging)....

Model-View-Controller (MVC)

MVC is an architectural pattern that separates an application into three main components: Model , View , and Controller , each with distinct responsibilities: Model: The data or business logic of the application. It...

Observer Pattern

Observer (also known as Publish/Subscribe or Listener) defines a one to many dependency between objects so that when one object (subject) changes state, all its dependents (observers) are notified automatically. The...

Outbox Pattern

The Outbox Pattern is an architectural pattern used to guarantee reliable, atomic, and consistent publication of events in distributed systems. Instead of attempting to send external messages within the same...

Prototype Pattern

(Note: Prototype is less commonly used in everyday backend work but worth knowing.) The Prototype pattern creates new objects by cloning an existing object, known as the prototype. This is handy when object creation is...

Proxy Pattern

A Proxy provides a placeholder or substitute for another object to control access to it. The proxy implements the same interface as the real subject and forwards requests to it, adding extra behavior either before or...

Repository Pattern

The Repository pattern is an abstraction over data storage that provides a collection like interface for accessing domain objects. Instead of the domain/business logic dealing directly with database queries or data...

Saga Pattern for Distributed Transactions

Distributed systems are allergic to “one big transaction.” If your workflow spans multiple services or multiple database shards , you don’t get the luxury of a single ACID transaction covering everything. The Saga...

Singleton

The Singleton ensures a class has only one instance and provides a global point of access to it. This is useful for shared resources like configuration, caches, or thread pools, where multiple instantiations could...

Strategy Pattern

Strategy defines a family of interchangeable algorithms, encapsulates each one, and makes them interchangeable at runtime. The core idea is to delegate a specific task (algorithm) to a subordinate object (the...

Template Method Pattern

Template Method defines the skeleton of an algorithm in a method, deferring some steps to subclasses. It allows subclasses to redefine certain steps of an algorithm without changing the algorithm’s overall structure....