๐Ÿงฉ Design patterns, taught in C#

Design patterns and SOLID principles, in modern C#.

The Gang of Four patterns and the SOLID principles, the patterns the .NET platform defines in its own guidelines, and the concurrency patterns, taught as decisions under forces rather than recipes to apply by reflex. Every chapter leads with where C# diverges from Java and where a pattern dissolves into a language feature, with new, real-domain C# 14 code on .NET 10 behind it and an xUnit and NSubstitute suite proving each example does what the chapter claims. Read it straight through, or jump to the part that answers the question you have right now.

.NET 10 C# 14 SOLID GoF patterns xUnit / NSubstitute

The parts

Fifteen parts, read in order the first time, with a set of appendices behind them. Each part page lists its chapters; each chapter stands on its own for a reader jumping in to solve one problem. The orientation part is the map; start there if you only have time for one page.

Part 0

Orientation

The toolchain (.NET 10 SDK, dotnet CLI, xUnit, NSubstitute), how to read the book, and the codetabs convention that sets modern C# idioms side by side.

1 chapterExplore โ†’
Part 1

Why This Is Not a GoF Retelling

Patterns as decisions under forces, and the claim that several 1994 catalogue entries are now C# language features rather than designs you write.

2 chaptersExplore โ†’
Part 2

What Modern C# Changes About the Catalogue

The feature map up front: event, delegates, yield and LINQ, nullable reference types, extension members, expression trees, source generators, reified generics, static abstract members, and value types, the modern C# 14 features that reshape how the Gang of Four catalogue reads against its 1994 assumptions.

2 chaptersExplore โ†’
Part 3

Principles

SOLID in idiomatic C#, including dependency inversion where the DI container ships in the base class library.

2 chaptersExplore โ†’
Part 4

The .NET Substrate

The Dispose pattern and IAsyncDisposable, value types and Span, nullable reference types and records, and proving a design works with xUnit and NSubstitute before the patterns chapters begin.

4 chaptersExplore โ†’
Part 5

Selecting and Varying Behaviour

Strategy, Template Method, State, and Command, and the delegate and keyed-service idioms that reshape them in C#.

4 chaptersExplore โ†’
Part 6

Creating Objects Under Control

Factory Method and Abstract Factory under reified generics, Builder displacement by required members and collection expressions, and Singleton as a DI lifetime.

3 chaptersExplore โ†’
Part 7

Composing and Adapting Structure

Adapter, Facade, and Bridge with conversion operators, Decorator and Proxy through DI decoration and DispatchProxy, and Composite and Flyweight over repeated data.

3 chaptersExplore โ†’
Part 8

Coordinating and Traversing

Observer as the event keyword, Mediator and Chain of Responsibility as a pipeline, Iterator as a compiler-generated state machine, and Visitor, Memento, and Interpreter.

4 chaptersExplore โ†’
Part 9

Idiomatic C#

Extension members, expression trees, source generators, Roslyn analyzers, and static abstract members: the C# machinery behind the book's most research-heavy part.

5 chaptersExplore โ†’
Part 10

Patterns the Platform Defines

The Options pattern, Tester-Doer against the Result debate, and the Task-based Asynchronous Pattern: named patterns the .NET platform specifies in its own guidelines.

3 chaptersExplore โ†’
Part 11

Concurrency Patterns

Patterns of usage rather than the async model: thread-safe creation, Active Object and Monitor Object on Channel, Producer-Consumer, pooling, and classic GoF patterns under concurrency.

6 chaptersExplore โ†’
Part 12

Patterns in the Wild

Shortcut patterns that are not anti-patterns, and the anti-patterns and pattern misuse to recognise, including pattern-shaped LLM output.

2 chaptersExplore โ†’
Part 13

Changing Inherited Code

Seams where C# is non-virtual by default, the dependency-breaking techniques that follow, and the Fowler and Feathers contrast applied to C#.

4 chaptersExplore โ†’
Part 14

Putting It Together

A shipping-domain subsystem exercising patterns from every part, and a closing chapter on reviewing pattern-shaped output from AI and LLM tools.

2 chaptersExplore โ†’
Part 15

Appendices

A build and toolchain reference, an xUnit reference, an NSubstitute reference, an xUnit test-patterns guide, a pattern-to-force quick reference, a code-first review of programming principles, and the C# 15 / .NET 11 delta.

7 chaptersExplore โ†’