docs/.NET Advance Design Pattern/02-design-pattern-categories
Edit on GitHub

title: "Design Pattern Categories" contentKey: "design-pattern-categories" section: "getting-started" accessLevel: "free" contentType: "doc" tags: ["dotnet", "design-patterns", "categories", "getting-started"] order: 2 sourceType: "same_repo" sourcePath: "docs/free/getting-started/02-design-pattern-categories.md" routePath: "/project/dotnet-advanced-design-patterns/preview/design-pattern-categories" isPublished: true

Design Pattern Categories

This document explains the four categories of design patterns covered in this repository: the three classic GoF (Gang of Four) categories plus Enterprise/Practical patterns used in production .NET applications.


Overview Mind Map


Category 1: Creational Patterns

What They Solve

Creational patterns abstract the instantiation process. They help make a system independent of how its objects are created, composed, and represented.

Core Question

"How should I create this object?"

When You Need Them

  • The concrete class to instantiate is determined at runtime.
  • Object creation is complex (many parameters, conditional logic, expensive setup).
  • You want to decouple client code from specific implementations.
  • You need families of related objects that must be used together.

Patterns in This Category

PatternOne-LinerThis Repo's Scenario
Factory MethodLet subclasses decide which class to instantiatePayment Gateways
Abstract FactoryCreate families of related objects without concrete typesCloud Storage (AWS/Azure)
BuilderConstruct complex objects step by stepInvoice Generation
PrototypeClone existing objects instead of creating from scratchFeature Flags
SingletonEnsure a class has only one instanceTelemetry Registry

Key Principle

"Program to an interface, not an implementation." Creational patterns let client code work with abstractions while the pattern handles which concrete class is actually instantiated.


Category 2: Structural Patterns

What They Solve

Structural patterns deal with class and object composition. They help you build larger structures from individual classes and objects while keeping the structure flexible and efficient.

Core Question

"How should I compose these objects together?"

When You Need Them

  • You need to integrate with a third-party library that has an incompatible interface.
  • You want to add responsibilities to objects dynamically.
  • You need to represent part-whole hierarchies.
  • You want to simplify a complex subsystem for consumers.
  • You need to share state efficiently across many objects.

Patterns in This Category

PatternOne-LinerThis Repo's Scenario
AdapterConvert one interface to anotherShipping Carriers
BridgeSeparate abstraction from implementationNotifications
CompositeTreat individual and composite objects uniformlyPermission Hierarchy
DecoratorAdd behavior dynamically by wrappingAPI Client Resilience
FacadeProvide a simple interface to a complex subsystemReport Generation
FlyweightShare fine-grained objects to save memoryTax Rates
ProxyProvide a surrogate to control accessInventory Service

Key Principle

"Favor composition over inheritance." Structural patterns achieve flexibility by composing objects at runtime rather than locking behavior into an inheritance hierarchy at compile time.


Category 3: Behavioral Patterns

What They Solve

Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. They describe not just patterns of objects and classes but also the patterns of communication between them.

Core Question

"How should these objects interact and divide responsibility?"

When You Need Them

  • You need to vary the algorithm used at runtime.
  • You want to decouple senders from receivers.
  • You need to traverse or operate on complex structures.
  • You want to model state-dependent behavior.
  • You need undo/redo functionality.
  • You want to define a processing pipeline.

Patterns in This Category

PatternOne-LinerThis Repo's Scenario
Chain of ResponsibilityPass requests along a chain until one handles itExpense Approval
CommandEncapsulate a request as an objectOrder Fulfillment
InterpreterDefine a grammar and build an interpreter for itSearch Query DSL
IteratorProvide sequential access to elementsPaginated API
MediatorCentralize complex communicationsCheckout Workflow
MementoCapture and restore state without violating encapsulationDocument Editor
ObserverNotify dependents when state changesHealthcare IoT
StateChange behavior when state changesOrder Lifecycle
StrategyDefine a family of interchangeable algorithmsPricing Engine
Template MethodDefine the skeleton of an algorithm in a base classDocument Export
VisitorDefine new operations without changing element classesFraud Detection

Key Principle

"Encapsulate what varies." Behavioral patterns identify the aspects of your application that vary and separate them from what stays the same.


Category 4: Enterprise / Practical Patterns

What They Solve

Enterprise patterns address concerns that emerge in real-world, production-grade applications — data access, distributed systems, configuration management, and domain modeling. They are not part of the original GoF catalog but are essential knowledge for any professional .NET developer.

Core Question

"How should I architect the layers and infrastructure of a production system?"

When You Need Them

  • You need a clean data access layer that is testable and swappable.
  • You must ensure transactional consistency across multiple repository operations.
  • You want to express domain logic as composable, testable rules.
  • You need to handle errors gracefully without exception-based control flow.
  • You must guarantee event delivery in distributed systems.
  • You want type-safe configuration with validation.

Patterns in This Category

PatternOne-LinerOrigin
RepositoryAbstract persistence behind a collection-like interfaceFowler's PoEAA
Unit of WorkTrack changes and commit as a single transactionFowler's PoEAA
SpecificationEncapsulate query criteria as composable objectsEvans' DDD
Result PatternRepresent success/failure explicitly as a return typeFunctional paradigm
CQRSSeparate command (write) and query (read) modelsGreg Young / DDD
Domain EventsPublish events from domain aggregatesEvans' DDD
OutboxReliably publish events using transactional outboxMicroservices
Null ObjectProvide a do-nothing default instead of nullBobby Woolf
Value ObjectImmutable objects with value-based equalityEvans' DDD
SagaManage distributed transactions via compensationGarcia-Molina (1987)
Options PatternBind configuration sections to typed objects.NET Core idiom
Policy PatternCompose business rules as first-class objectsDDD / Clean Arch

Key Principle

"Make the implicit explicit." Enterprise patterns take concerns that are often buried in infrastructure code (transactions, event delivery, configuration) and make them first-class, testable, documented parts of your architecture.


How the Categories Relate

Progression Path

  1. Creational patterns get the right objects into existence.
  2. Structural patterns connect those objects into useful structures.
  3. Behavioral patterns define how those structures communicate and process work.
  4. Enterprise patterns combine all of the above into production architectures.

Category Comparison Table

AspectCreationalStructuralBehavioralEnterprise
FocusObject creationObject compositionObject interactionSystem architecture
GranularitySingle objectSmall groupCommunication flowEntire layer/service
ComplexityLow-MediumMediumMedium-HighHigh
Count in GoF5711N/A (not GoF)
Count here571112
Learn firstFactory, BuilderAdapter, DecoratorStrategy, ObserverRepository, Result
Interview focusSingleton, FactoryDecorator, ProxyStrategy, State, CmdCQRS, Repository

Next Steps