Introduction
- Who This Book Is For
- On Code Examples
- Preface to the 2nd Edition
The SOLID Design Principles
- Single Responsibility Principle
- Open-Closed Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
The Functional Perspective
- Function Basics
- Functional Literals in C#
- Storing Functions in C#
- Functional Literals in F#
- Composition
- Functional-Related Language Features
- Creational Patterns
Builder
- Scenario
- Simple Builder
- Fluent Builder
- Communicating Intent
- Composite Builder
- Builder Parameter
- Builder Extension with Recursive Generics
- Lazy Functional Builder
- DSL Construction in F#
- Summary
Factories
- Scenario
- Factory Method
- Asynchronous Factory Method
- Factory
- Inner Factory
- Abstract Factory
- Delegate Factories in IoC
- Functional Factory
- Summary
Prototype
- Deep vs. Shallow Copying
- ICloneable Is Bad
- Deep Copying with a Special Interface
- Deep Copying Objects
- Duplication via Copy Construction
- Serialization
- Prototype Factory
- Summary
Singleton
- Singleton by Convention
- Classic Implementation
- The Trouble with Singleton
- Singletons and Inversion of Control
- Monostate
- Multiton
- Summary
- Structural Patterns
Adapter
- Scenario
- Adapter
- Adapter Temporaries
- The Problem with Hashing
- Property Adapter (Surrogate)
- Generic Value Adapter
- Adapter in Dependency Injection
- Adapters in the .NET Framework
- Summary
Bridge
- Conventional Bridge
- Dynamic Prototyping Bridge
- Summary
Composite
- Grouping Graphic Objects
- Neural Networks
- Shrink Wrapping the Composite
- Composite Specification
- Summary
Decorator
- Custom String Builder
- Adapter-Decorator
- Multiple Inheritance with Interfaces
- Multiple Inheritance with Default Interface Members
- Dynamic Decorator Composition
- Static Decorator Composition
- Functional Decorator
- Summary
Façade
- Magic Squares
- Building a Trading Terminal
- An Advanced Terminal
- Where’s the Façade?
- Summary
Flyweight
- User Names
- Text Formatting
- Summary
Proxy
- Protection Proxy
- Property Proxy
- Value Proxy
- Composite Proxy: SoA/AoS
- Composite Proxy with Array-Backed Properties
- Virtual Proxy
- Communication Proxy
- Dynamic Proxy for Logging
- Summary
- Behavioral Patterns
Chain of Responsibility
- Scenario
- Method Chain
- Broker Chain
- Summary
Command
- Scenario
- Implementing the Command Pattern
- Undo Operations
- Composite Commands (a.k.a. Macros)
- Functional Command
- Queries and Command Query Separation
- Summary
Interpreter
- Numeric Expression Evaluator
- Interpretation in the Functional Paradigm
- Summary
Iterator
- Array-Backed Properties
- Let’s Make an Iterator
- Improved Iteration
- Iterator Adapter
- Summary
Mediator
- Chat Room
- Mediator with Events
- Introduction to MediatR
- Summary
Memento
- Bank Account
- Undo and Redo
- Using Memento for Interop
- Summary
Null Object
- Scenario
- Intrusive Approaches
- Null Object
- Dynamic Null Object
- Summary
Observer
- Events
- Weak Event Pattern
- Event Streams
- Property Observers
- Observable Collections
- Declarative Subscriptions in Autofac
- Summary
State
- State Driven State Transitions
- Handmade State Machine
- Switch-Based State Machine
- Encoding Transitions with Switch Expressions
- State Machines with Stateless
- Summary
Strategy
- Dynamic Strategy
- Static Strategy
- Equality and Comparison Strategies
- Functional Strategy
- Summary
Template Method
- Game Simulation
- Functional Template Method
- Summary
Visitor
- Intrusive Visitor
- Reflective Printer
- What is Dispatch?
- Dynamic Visitor
- Classic Visitor
- Acyclic Visitor
- Functional Visitor
- Summary