SERIES

Design Patterns A → Z in C# / .NET

A practical, hands-on guide to the 23 Gang of Four design patterns for C# developers. Every chapter starts from a real symptom in code, walks through the classical shape, and then shows the modern .NET 10 implementation — records, dependency injection, pattern matching, and the libraries that already do most of the work. Pick one chapter when you have a problem in front of you, or read in order for the full map. Available in English and Vietnamese.

26 articles · 4 groups · C# / .NET 10 · EN / VI

Overview (3)

Creational Patterns (5)

Structural Patterns (7)

06
Adapter Pattern in C#: Make Foreign APIs Fit Your Code

Adapter pattern in C# / .NET 10: wrap legacy SDK calls in your interfaces — sync-to-async, snake_case to PascalCase, and exception-to-Result conversion.

Beginner 7 min read
07
Bridge Pattern in C#: Stop the 3x3 Class Explosion

Bridge pattern in C# / .NET 10: separate an abstraction (notification style) from its implementation (delivery channel) to keep N+M classes instead of N*M.

Advanced 8 min read
08
Composite Pattern in C#: Trees with Uniform Operations

Composite pattern in C# / .NET 10: a shared interface for leaves and groups so totals, rendering, and validation work the same at every level of a tree.

Intermediate 8 min read
09
Decorator Pattern in C#: Logging, Retry, Caching Wrappers

Decorator pattern in C# / .NET 10: wrap a service with logging, retry, and caching without modifying it, and how Scrutor.Decorate automates the registration.

Intermediate 8 min read
10
Facade Pattern in C#: One Service for Many Subsystems

Facade pattern in C# / .NET 10: collapse six injections into one application service that fans out, without leaking the inner classes back to the caller.

Beginner 7 min read
11
Flyweight Pattern in C#: Share Immutable Instances Sanely

Flyweight pattern in C# / .NET 10: share immutable instances to cut allocations on a hot path, with examples from string interning to product badge caches.

Advanced 7 min read
12
Proxy Pattern in C#: Lazy Loading, Auth, and Remote Stubs

Proxy pattern in C# / .NET 10: lazy-load via EF Core proxies, add authorisation around a service, and recognise gRPC clients as remote proxies.

Intermediate 8 min read

Behavioral Patterns (11)

13
Chain of Responsibility in C#: Pipelines and Middleware

Chain of Responsibility in C# / .NET 10: build validation pipelines like ASP.NET Core middleware, with handlers that can forward or stop the chain.

Intermediate 7 min read
14
Command Pattern in C#: Records, Handlers, and Undo

Command pattern in C# / .NET 10: encapsulate a request as a record, dispatch it to a handler, and how MediatR is this pattern shipped as a NuGet.

Intermediate 7 min read
15
Interpreter Pattern in C#: When and How to Build a DSL

Interpreter pattern in C# / .NET 10: build a tiny DSL for discount rules, when Expression trees beat hand-written interpreters, and when to use neither.

Advanced 7 min read
16
Iterator Pattern in C#: yield, IEnumerable, IAsyncEnumerable

Iterator pattern in C# / .NET 10: how yield return and IEnumerable are this pattern, and when IAsyncEnumerable lets you stream remote data lazily.

Beginner 6 min read
17
Mediator Pattern in C#: MediatR Notifications and Hubs

Mediator pattern in C# / .NET 10: peers publish to a hub instead of calling each other, with MediatR notifications as the standard implementation.

Intermediate 6 min read
18
Memento Pattern in C#: Snapshots for Undo and Rollback

Memento pattern in C# / .NET 10: capture state into snapshots for undo, transactional rollback, and time-travel debugging using record and with.

Intermediate 7 min read
19
Observer Pattern in C#: Events and IObservable

Observer pattern in C# / .NET 10: notify subscribers when state changes via event, IObservable, INotifyPropertyChanged, or Channel — pick the right one for the case.

Beginner 6 min read
20
State Pattern in C#: Order Lifecycles with Stateless

State pattern in C# / .NET 10: model an order's lifecycle as states with allowed transitions, using pattern matching or the Stateless library.

Intermediate 8 min read
21
Strategy Pattern in C#: Func, DI, or Interface?

Strategy pattern in C# / .NET 10: when a Func delegate is enough, when an injected interface earns its keep, and how Strategy differs from State and Command.

Beginner 7 min read
22
Template Method in C#: Inheritance Hooks vs Strategy

Template Method pattern in C# / .NET 10: when an abstract base with hook methods is right, when Strategy injection wins, and how to avoid inheritance lock-in.

Beginner 8 min read
23
Visitor Pattern in C#: switch Expressions and Double Dispatch

Visitor pattern in C# / .NET 10: when switch expressions with pattern matching beat the GoF double-dispatch hierarchy, and when classical Visitor still wins.

Advanced 8 min read