Library

Patterns

A growing set of design patterns with implementation notes, tradeoffs, and cross-stack integration guidance.

11 patterns

Chain of Responsibility

Behavioral

Pass requests along a chain of handlers until one of them handles the request or the request reaches the end of the chain.

Problem: A request must pass through multiple possible handlers, but the sender should not need to know which handler will process it.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Chain of Responsibility is useful for validation pipelines, support routing, approval flows, and any system where requests may be processed by different handlers in sequence.

View pattern

Command

Behavioral

Encapsulate a request as an object so it can be invoked, queued, logged, or undone independently of the receiver that performs the work.

Problem: A system needs to trigger actions without tightly coupling the code that requests an operation to the code that performs it, and it may also need queuing, history, or undo support.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Commands work well for UI actions, background jobs, workflow steps, and undoable operations because invokers can trigger commands without depending on receiver details.

View pattern

Interpreter

Behavioral

Represent grammar rules as objects and interpret sentences by evaluating an abstract syntax tree or expression chain.

Problem: You need to define a small language or expression grammar and evaluate it consistently across the application.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Interpreter is useful for calculators, rule engines, simple DSLs, and command parsing systems where a structured grammar must be evaluated.

View pattern

Iterator

Behavioral

Provide a way to access elements of an aggregate sequentially while hiding the underlying representation.

Problem: A collection needs to be traversed without exposing how it is stored internally.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Iterator is useful for pagination, custom collections, ordered traversal, and any case where clients should not know the internal data structure.

View pattern

Mediator

Behavioral

Define an object that encapsulates communication between a set of objects, keeping them from referring to each other directly.

Problem: Multiple objects need to coordinate behavior, but direct references between them create tight coupling and complex dependencies.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Mediator is useful for chat systems, form coordination, workflow orchestration, and any domain where many components must collaborate without knowing about each other.

View pattern

Memento

Behavioral

Capture and externalize an object's state so it can be restored to a previous point in time.

Problem: An object's internal state must be saved and restored later without exposing its implementation details.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Memento is useful for undo/redo, checkpoints, draft recovery, and any workflow where state history matters.

View pattern

Observer

Behavioral

Define a subscription mechanism so multiple observers can react to subject events without the subject knowing concrete subscriber details.

Problem: A system needs to notify multiple dependent objects when state changes occur, but hardcoding those dependencies makes the design rigid and tightly coupled.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Observers work well inside a single application boundary for UI events, domain events, and in-process notifications where subscribers change dynamically.

View pattern

State

Behavioral

Allow an object to alter its behavior when its internal state changes by delegating state-specific behavior to separate state objects.

Problem: An object behaves differently depending on its internal state, and conditional logic is becoming hard to manage.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: State is useful for workflows, media players, order lifecycles, and any domain where behavior changes as the object moves through a lifecycle.

View pattern

Strategy

Behavioral

Encapsulate a family of algorithms or behaviors behind a common contract so they can be selected and swapped cleanly.

Problem: A system needs to switch between interchangeable behaviors without hardcoding branching logic everywhere.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Strategies can cross codebases through shared contracts, API selection rules, or runtime configuration.

View pattern

Template Method

Behavioral

Define the skeleton of an algorithm in a base class and let subclasses override selected steps without changing the overall structure.

Problem: Several classes share the same algorithm structure, but some steps need to vary between implementations.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Template Method is useful when you have repeated workflows with a common sequence of steps, such as processing orders, generating reports, and importing data.

View pattern

Visitor

Behavioral

Separate an algorithm from the object structure it operates on by moving behavior into visitor objects.

Problem: You need to perform operations across a set of different object types without stuffing all the logic into the objects themselves.

Languages: typescript, java, python, angular, react, react-native, csharp, dotnet

Integration: Visitor is useful for AST processing, reporting, cart calculations, and exporting object structures to alternate formats.

View pattern