🔥 Pragmatic .NET Code Rules Course is on Presale - 40% off!BUY NOW
📘 Design Patterns that Deliver · 10 patterns + 2 AI tutors1250+ copies sold · instant download
By Stefan Đokić · Microsoft MVP

Stop guessing design patterns. Start shipping the right one.

Ten production-grade C# patterns — the five everyone needs (Builder, Decorator, Strategy, Adapter, Mediator) plus five that ship real systems (Result, Pipeline, Specification, Factory, State). Each from a real problem to working code — with unit tests, trade-offs, a GitHub repo, 100 interview Q&As, and a built-in AI tutor.

Instant download PDF + EPUB GitHub repo included AI tutor lifetime updates

★★★★★Rated 5/5 · loved by 1250+ developers
Design Patterns that Deliver - C# design patterns ebook cover
Microsoft MVP1250+ copies sold20,000+ newsletter readers102k+ LinkedIn10 patterns · 20 mini-projects★★★★★
Start here

Three ways in — pick yours

Whether you're just browsing, want to read before you buy, or already own the book — there's a door for you.

Free
PATH 01 · JUST BROWSING

Find your pattern in seconds

Describe the problem you're stuck on. The free AI Pattern Picker recommends the right C#/.NET pattern with a tutorial for each.

Try the Pattern Picker →
No signup
PATH 02 · READ FIRST

Read a full chapter, free

The entire Builder chapter is open in the web reader — real copyable code, diagrams, and the AI tutor on every example.

Read the Builder chapter →
For owners
PATH 03 · YOU OWN IT

Ask the book anything

Sign in with your purchase and chat with Ask the Book — an AI tutor that answers strictly from the book, cited by chapter.

Open Ask the Book →
Recommended by a Microsoft MVP★★★★★
"A quick and enjoyable read about the most important design patterns in C#. The examples were refreshing, and I especially liked being able to access the source code. If you're just starting or need a refresher, this book will be your design patterns companion."
MJ
Milan Jovanović
Microsoft MVP · Creator of Pragmatic Clean Architecture
The gap

You know the theory. But in the IDE, the code still looks wrong.

You've read the Gang of Four. You've watched the tutorials. You can name patterns on a whiteboard. Then a real problem lands and you freeze:

  • "Should this be a Strategy or a Factory?"
  • "Should I throw here, or return a Result?"
  • "How does this pattern even work with DI?"
  • "The example online is a Pizza class... how does that help me?"

The gap between knowing a pattern and using it in production is massive.
That's exactly what this ebook closes.

C# design patterns real-world implementation example
The transformation

What changes after you read this

Before

  • Copy-paste pattern examples from StackOverflow
  • Can't decide which pattern fits the problem
  • Overengineer simple features with the wrong abstraction
  • Struggle to explain patterns in interviews
  • Every tutorial uses Pizza or Animal classes
  • No idea how patterns work with dependency injection

After

  • Choose the right pattern in minutes
  • Refactor messy code into clean, maintainable architecture
  • Know exactly when to use - and when NOT to use - each one
  • Speak confidently about patterns in any interview
  • Have production-ready C# code with unit tests you can adapt
  • Master advanced variants (Fluent/Step Builder, Scrutor, MediatR, keyed DI)
The system

10 patterns. Real problems. Real code.

Each pattern starts with a real-world problem you'd actually hit in production - then the solution, the UML, the advanced variants, unit tests, and when NOT to use it.

The foundational five

🧱
PATTERN 01

Builder Pattern

Stop creating objects with 10-parameter constructors. From basic to Fluent, Director, Nested, FluentValidation, and a Step Builder the compiler enforces.

Fluent BuilderDirector ClassStep BuilderFluentValidationTest Data Builder
🎨
PATTERN 02

Decorator Pattern

Add caching, logging, or retry without touching the original class. Compose the onion in DI with Scrutor, Polly resilience, and HybridCache.

Scrutor + DIPolly v8HybridCacheCross-cutting concerns
PATTERN 03

Strategy Pattern

Swap algorithms at runtime without if-else chains. Keyed DI, a factory for dynamic choice, and configuration-based selection.

Keyed DI (.NET 8)Strategy + FactoryConfig selectionLifetimes
🔌
PATTERN 04

Adapter Pattern

Integrate third-party APIs and legacy systems without rewriting everything. Object vs Class adapters, error translation, a cloud-agnostic storage layer.

Object vs ClassCloud ProvidersError translationLegacy wrapping
🚀
PATTERN 05

Mediator Pattern

Decouple components and orchestrate communication cleanly. From a basic mediator to MediatR with validation, transaction, and logging pipeline behaviors — plus an honest take on licensing.

MediatR pipelinesTransaction behaviorNotificationsSource-generated alt

Five more that ship real systems

🛤️
PATTERN 06

Result Pattern

Model expected failures as values, not exceptions. Railway-oriented Bind/Map/Match — including async — and clean ProblemDetails responses.

Railway-orientedAsync Bind/MapProblemDetailsErrorOr / FluentResults
🔗
PATTERN 07

Pipeline / Chain of Responsibility

The pattern behind ASP.NET middleware. Build your own typed, async pipeline of focused handlers that each decide whether to continue.

ASP.NET middlewareAsync chainMediatR behaviorsShort-circuit
🔎
PATTERN 08

Specification Pattern

Stop drowning the repository in query methods. Composable rules that translate to EF Core SQL — done with parameter rebinding, not the Invoke trick that throws.

EF Core translationAnd / Or / NotExpressionVisitorArdalis.Specification
🏭
PATTERN 09

Factory Patterns

Stop welding code to concrete types with new. Factory Method, Abstract Factory, and the modern .NET way — keyed DI, factory delegates, ActivatorUtilities.

Keyed DIActivatorUtilitiesFunc<T>IHttpClientFactory
🚦
PATTERN 10

State Pattern

Kill the boolean soup of IsPaid/IsShipped flags. Model a lifecycle so illegal transitions are impossible — guarded enums, class-per-state, optimistic concurrency, and Stateless for big workflows.

Guarded transitionsClass-per-stateOptimistic concurrencyStateless library
Built-in AI

AI tools, not one static PDF

Most pattern books are static. This one ships with a suite of AI tools — three free for everyone, plus a tutor that knows the book. Try the free one right here.

Free · live demo

Pattern Picker

Describe a real problem in your C#/.NET code and get the right pattern in seconds — every result links to a full tutorial, and to the book chapter where one exists.

Free. Grounded in TheCodeMan's .NET pattern catalog — every result links to a full tutorial.
🔒 For book owners

Ask the Book

An AI tutor that answers strictly from the book — production-grade, cited by chapter. Not generic internet code. Here's what a real answer looks like:

ask-the-book
Should I throw or return a Result when shipping an order that's already shipped?
Return a Result. "Already shipped" is an expected outcome a user can trigger, so model it as a value and map it to a 409 Conflict — keep throw for true invariant violations. In the State chapter the guarded transition returns Result.Failure and the endpoint uses Match to pick the status code.📖 Cited: State · Result chapters
And how do I keep two requests from shipping it twice?
Add optimistic concurrency — a [Timestamp] rowversion — and handle DbUpdateConcurrencyException. The in-memory guard stops illegal transitions; the rowversion stops concurrent ones.📖 Cited: State chapter
Owners: open Ask the Book →

Three free AI tools for everyone · Ask the Book unlocks when you own it.

The full package

You don't just get a PDF

Everything you need to understand, apply, and explain design patterns in real .NET projects.

📘

The Ebook

  • 10 patterns, problem to production
  • Real scenarios + unit tests, no toy classes
  • UML/Mermaid diagrams & trade-offs
  • Pros, cons & when NOT to use
💻

GitHub Repository

  • 20 mini-projects, complete C#
  • Clone, run, and modify instantly
  • Every pattern variation implemented
  • Bonus: code in 4 more languages
🤖

AI Tutor — Ask the Book

  • Answers strictly from the book
  • Cited by chapter, production-grade
  • Plus the free Pattern Picker
  • Read online with AI on every example
🎯

Interview Prep Ebook

  • 100 design pattern questions
  • Detailed answers with code
  • Covers all major GoF patterns
  • Built for senior-level interviews
📖

EPUB + Web Reader

Read on any device, or online with copyable code and an AI tutor on every example.

Quick-Reference Guide

A pattern decision cheat sheet: when to use vs. when not to, DI integration at a glance.

📄

100 Interview Q&As

With a working code example behind every single answer.

Ebook + repo + AI tutor + interview prep + cheat sheets + EPUB · all for $32.99

Proof

1250+ developers already use these patterns

Real feedback from engineers - from juniors to Microsoft MVPs - who put this ebook to work.

★★★★★

"Design Patterns ebook is a quick and enjoyable read about the most important design patterns in C#. The examples were refreshing, and I especially liked being able to access the source code. If you're just starting or need a refresher, this book will be your design patterns companion."

MJ
Milan Jovanović
Microsoft MVP
★★★★★

"I love the simplicity of how every pattern is explained. The real-life examples are an incredible way to provide context and understand why we are choosing this pattern. By providing the writer's point of view we can evaluate the pros and cons and decide which is better for our particular use case."

RA
Raul Fernando Aillon Salinas
Software Developer
★★★★★

"This ebook shows that good technical information doesn't have to be buried in hundreds of pages of fluff. Exactly what a developer wants to read - core information on what a specific technology is about and how to apply it."

JO
Jeroen Opmeer
C#/.NET Senior Developer
★★★★★

"Each pattern is explained step by step, with access to a GitHub repository, making it easy for everyone to grasp the material. A genuinely practical take on design patterns in C#."

NK
Nikola Knezević
Software Developer, Content Creator
★★★★★

"It's amazing, with nice visualization which helps a lot for a better understanding of how patterns work. One of the points I like is mentioning the Pros and Cons - they help you decide which pattern is suitable for your case."

SE
Saeed Esmaeelinejad
Senior Software Engineer
★★★★★

"This book is a very fun and interesting way to get into the world of design patterns. It also has everything you need to start applying those patterns in your application. Highly recommended."

SM
Stefan Milošević
Senior Software Engineer
Stefan Đokić, Microsoft MVP and author of Design Patterns that Deliver
Microsoft MVP

Written by a developer, for developers.

Hi, I'm Stefan Đokić - Microsoft MVP and Senior Software Engineer with years of experience building production .NET systems.

I wrote this ebook because I was frustrated with pattern books that use toy examples. Every pattern in this book comes from a real problem I've solved in production code - not Pizza classes, not abstract shapes.

I teach 20,000+ subscribers through my newsletter, and 102k+ followers follow my content on LinkedIn.

20,000+
Newsletter
102k+
LinkedIn
8,000+
Twitter / X
One simple price

Everything, for less than a lunch out.

Design Patterns that Deliver

Ebook + GitHub repo + AI tutor + interview prep + cheat sheets

$32.99

One-time payment · lifetime access · no subscription

  • The full ebook in PDF + EPUB
  • 10 patterns (5 foundational + 5 production)
  • GitHub repo: 20 runnable mini-projects
  • Ask-the-Book AI tutor, cited by chapter
  • 100 interview questions & answers
  • Quick-reference pattern decision guide
  • Lifetime access + all future updates
Get the Ebook - $32.99 →

Instant download · Secure checkout via Lemon Squeezy

Why developers buy this

Instant access
Download the ebook and clone the repo seconds after checkout.
💻
Real, runnable code
20 mini-projects you can open, run, and adapt today.
🤖
An AI tutor that knows it
Ask the Book answers from these exact chapters, cited.
🔁
Lifetime updates
Buy once, get every future update to the book and code free.
Honest fit check

Is this ebook right for you?

Probably not, if you…

  • Are a complete beginner still learning C# basics
  • Want a reference for all 23 GoF patterns
  • Prefer abstract theory over practical code
  • Are looking for language-agnostic content only

Built for developers who…

  • Are .NET / C# developers (mid-level or senior)
  • Know what patterns are but struggle to apply them
  • Want production-ready code with tests, not textbook theory
  • Are preparing for senior-level interviews
  • Want cleaner, more maintainable architecture
  • Lead a team and want patterns everyone can adopt
The full table of contents

Exactly what's inside

Click any pattern to expand. Every chapter follows the same problem → solution → advanced variants → tests → when-not-to-use flow.

🧱 Builder Pattern 9 topics+
Record + required vs. a builder
Classic, Fluent & Director
Nested builders (config lambdas)
Step Builder (compiler-enforced)
FluentValidation in Build()
Test Data Builders + a real test
Thread-safety & trade-offs
Pros & Cons
When NOT to Use It
🎨 Decorator Pattern 8 topics+
Coffee → cross-cutting concerns
Caching, logging, Polly resilience
Match retry to real exceptions
HybridCache & stampede
Composing the onion with Scrutor
Captive-dependency lifetime trap
Testing + Pros & Cons
When NOT to Use It
⚡ Strategy Pattern 8 topics+
From if-else to a family of classes
Strategy vs. domain polymorphism
Keyed DI (.NET 8) + lifetimes
A factory for dynamic choice
Real case: payment gateways
Strategy + Decorator
Config-driven selection + test
Pros, Cons & when NOT to use
🔌 Adapter Pattern 8 topics+
Legacy payment gateway
Object vs Class adapter
Error translation
Cloud-agnostic storage (S3/Azure)
Stream ownership & lifetimes
When an adapter "lies"
Testing + Pros & Cons
When NOT to Use It
🚀 Mediator Pattern 9 topics+
Chatroom → MediatR
Request / response handlers
Validation behavior (ValidateAsync)
Transaction behavior
Notifications & publisher strategy
Testing a behavior
Licensing & source-generated alts
Pros & Cons
When NOT to Use It
🛤️ Result Pattern 9 topics+
Exceptions for the non-exceptional
Minimal Result<T> + non-generic
Railway: Bind / Map / Match
Async railway (the part most skip)
Aggregating validation errors
Mapping to ProblemDetails
Benchmark: throw vs. Result
Pros & Cons
When NOT to Use It
🔗 Chain of Responsibility & Pipelines 9 topics+
CoR vs. Pipeline
ASP.NET middleware as the pattern
A typed, async domain pipeline
Compose once; terminal handler
Short-circuiting
Relationship to MediatR behaviors
Testing a handler
Pros & Cons
When NOT to Use It
🔎 Specification Pattern 9 topics+
The repository method explosion
An EF-translatable specification
Composing with an ExpressionVisitor
Using it against EF Core
Proving it's real SQL
One rule, two uses (+ test)
Includes / paging (Ardalis)
Pros & Cons
When NOT to Use It
🏭 Factory Patterns 9 topics+
`new` welds you to a type
IHttpClientFactory in the BCL
Factory Method & Abstract Factory
Keyed DI + a thin factory
Func<T> & ActivatorUtilities
The captive-dependency trap
Testing a factory
Pros & Cons
When NOT to Use It
🚦 State Pattern 9 topics+
Boolean soup & illegal transitions
Guarded transitions (one guard)
Throw vs. return a Result
Class-per-state (singletons)
Optimistic concurrency (rowversion)
Entry/exit actions & Stateless
Testing illegal transitions
Pros & Cons
When NOT to Use It
🎯 Bonus: Interview Prep 3 topics+
100 Design Pattern Interview Questions
Detailed Answers with Explanations
Covers All Major GoF Patterns
🤖 Bonus: AI Tutor & Web Reader 3 topics+
Ask the Book — answers cited by chapter
Free Pattern Picker for any problem
Read online with copyable code
Questions

Frequently asked questions

Which patterns does the book cover?+

Ten production patterns in modern C#: five foundational ones - Builder, Decorator, Strategy, Adapter, Mediator - plus five that ship real systems - Result, Pipeline (Chain of Responsibility), Specification, Factory, and State. Each goes from a real problem to working code with unit tests, trade-offs, and when-not-to-use guidance.

What are the AI tools, and which are free?+

Two. The Pattern Picker is free for everyone - describe a problem and get the right C#/.NET pattern with a tutorial link. Ask the Book is an AI tutor for owners that answers strictly from the book, cited by chapter - accurate, production-grade, not generic internet code. You can try the Pattern Picker live on this page.

Are design patterns still relevant in modern .NET?+

Absolutely. MediatR (Mediator), Scrutor (Decorator), Polly (resilience), IHttpClientFactory (Factory), keyed DI, and ASP.NET middleware (Chain of Responsibility) are all pattern implementations used daily in production .NET around dependency injection, pipelines, and Clean Architecture.

How is this different from other design patterns books?+

Most pattern books explain theory with abstract examples (Pizza, Animal, Shape classes). This ebook starts every pattern with a real production problem, shows the solution in C# with unit tests and trade-offs, then explores advanced variants. You also get a GitHub repo with 20 runnable mini-projects and a built-in AI tutor.

What knowledge level do I need?+

You should be comfortable with C# and basic .NET development. The ebook is designed for intermediate to senior developers who know the language but want to level up their architecture and design skills. It's not for absolute beginners.

Do I get code I can use in my own projects?+

Yes. You get full access to a GitHub repository with 20 mini-projects - one for each pattern and each advanced variant. The code is structured, documented, and ready to clone, run, and adapt.

What formats does the ebook come in?+

You get PDF and EPUB, plus a web reader so you can read online with copyable code and the AI tutor on every example. Both light and dark modes are included.

Is there a refund policy?+

The ebook is a digital product delivered instantly. If you're not satisfied, reach out directly and we'll work it out. 1250+ developers have purchased it and the feedback has been overwhelmingly positive.

Stop reading about patterns. Start shipping them.

Real C# code you can apply in your next PR.

Get the Ebook - $32.99 →

Instant download · PDF + EPUB · GitHub repo · AI tutor · 1250+ copies sold

Design Patterns that Deliver10 patterns + AI tutor · instant download
$32.99Get it