Implement design patterns in .NET using the latest versions of the C# and F# languages. This book provides a comprehensive overview of the field of design patterns as they are used in today's developer toolbox.
Using the C# programming language, Design Patterns in .NET explores the classic design pattern implementation and discusses the applicability and relevance of specific language features for the purpose of implementing patterns. You will learn by example, reviewing scenarios where patterns are applicable. MVP and patterns expert Dmitri Nesteruk demonstrates possible implementations of patterns, discusses alternatives and pattern inter-relationships, and illustrates the way that a dedicated refactoring tool (ReSharper) can be used to implement design patterns with ease.
What You'll Learn
Know the latest pattern implementations available in C# and F#
Refer to researched and proven variations of patterns
Study complete, self-contained examples including many that cover advanced scenarios
Use the latest implementations of C# and Visual Studio/ReSharper
Who This Book Is For
Developers who have some experience in the C# language and want to expand their comprehension of the art of programming by leveraging design approaches to solving modern problems
Author(s): Dmitri Nesteruk
Publisher: Apress
Year: 2019
Language: English
Pages: 359
Table of Contents
About the Author
Introduction
Part I: Introduction
Chapter 1: The SOLID Design Principles
Single Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Chapter 2: The Functional Perspective
Function Basics
Functional Literals in C#
Storing Functions in C#
Functional Literals in F#
Composition
Functional-Related Language Features
Part II: Creational Patterns
Chapter 3: Builder
Scenario
Simple Builder
Fluent Builder
Communicating Intent
Composite Builder
Builder Parameter
Fluent Interface Inheritance
DSL Construction in F#
Summary
Chapter 4: Factories
Scenario
Factory Method
Factory
Inner Factory
Logical Separation
Abstract Factory
Functional Factory
Summary
Chapter 5: 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
Chapter 6: Singleton
Singleton by Convention
Classic Implementation
Lazy Loading
The Trouble with Singleton
Singletons and Inversion of Control
Monostate
Summary
Part III: Structural Patterns
Chapter 7: Adapter
Scenario
Adapter
Adapter Temporaries
The Problem with Hashing
Property Adapter (Surrogate)
Adapters in the .NET Framework
Summary
Chapter 8: Bridge
Conventional Bridge
Dynamic Prototyping Bridge
Summary
Chapter 9: Composite
Grouping Graphic Objects
Neural Networks
Shrink Wrapping the Composite
Summary
Chapter 10: Decorator
Custom String Builder
Adapter-Decorator
Multiple Inheritance
Dynamic Decorator Composition
Static Decorator
Functional Decorator
Summary
Chapter 11: Façade
Building a Trading Terminal
An Advanced Terminal
Where’s the Façade?
Summary
Chapter 12: Flyweight
Usernames
Text Formatting
Summary
Chapter 13: Proxy
Protection Proxy
Property Proxy
Virtual Proxy
Communication Proxy
Summary
Part IV: Behavioral Patterns
Chapter 14: Chain of Responsibility
Scenario
Method Chain
Broker Chain
Summary
Chapter 15: Command
Scenario
Implementing the Command Pattern
Undo Operations
Composite Commands
Functional Command
Queries and Command Query Separation
Summary
Chapter 16: Interpreter
Numeric Expression Evaluator
Lexing
Parsing
Using Lexer and Parser
Interpretation in the Functional Paradigm
Summary
Chapter 17: Iterator
Array-Backed Properties
Let’s Make an Iterator
Improved Iteration
Summary
Chapter 18: Mediator
Chat Room
Mediator with Events
Summary
Chapter 19: Memento
Bank Account
Undo and Redo
Summary
Chapter 20: Null Object
Scenario
Intrusive Approach
Null Object
Design Improvements
Null Object Virtual Proxy
Dynamic Null Object
Summary
Chapter 21: Observer
Weak Event Pattern
Property Observers
Dependency Problems
Event Streams
Observable Collections
Declarative Subscriptions
Summary
Chapter 22: State
State-Driven State Transitions
Handmade State Machine
State Machines with Stateless
Types, Actions, and Ignoring Transitions
Reentrancy Again
Hierarchical States
More Features
Summary
Chapter 23: Strategy
Dynamic Strategy
Static Strategy
Functional Strategy
Summary
Chapter 24: Template Method
Game Simulation
Functional Template Method
Summary
Chapter 25: Visitor
Intrusive Visitor
Reflective Printer
Functional Reflective Visitor
Improvements
What Is Dispatch?
Dynamic Visitor
Classic Visitor
Implementing an Additional Visitor
Acyclic Visitor
Functional Visitor
Summary
Index