Design Patterns in .NET (eBook)
XV, 359 Seiten
Apress (Verlag)
978-1-4842-4366-4 (ISBN)
- 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
Dmitri Nesteruk is a quantitative analyst, developer, course and book author, and an occasional conference speaker. His interests lie in software development and integration practices in the areas of computation, quantitative finance, and algorithmic trading. His technological interests include C# and C++ programming as well as high-performance computing using technologies such as CUDA and FPGAs. He has been a C# MVP since 2009.
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 LearnKnow the latest pattern implementations available in C# and F#Refer to researched and proven variations of patternsStudy complete, self-contained examples including many that cover advanced scenariosUse the latest implementations of C# and Visual Studio/ReSharperWho This Book Is ForDevelopers 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
Table of Contents 4
About the Author 12
Introduction 13
Part I: Introduction 16
Chapter 1: The SOLID Design Principles 17
Single Responsibility Principle 17
Open-Closed Principle 20
Liskov Substitution Principle 28
Interface Segregation Principle 31
Dependency Inversion Principle 36
Chapter 2: The Functional Perspective 40
Function Basics 40
Functional Literals in C# 43
Storing Functions in C# 43
Functional Literals in F# 46
Composition 48
Functional-Related Language Features 49
Part II: Creational Patterns 51
Chapter 3: Builder 53
Scenario 53
Simple Builder 56
Fluent Builder 57
Communicating Intent 58
Composite Builder 60
Builder Parameter 64
Fluent Interface Inheritance 67
DSL Construction in F# 71
Summary 73
Chapter 4: Factories 74
Scenario 74
Factory Method 76
Factory 78
Inner Factory 78
Logical Separation 80
Abstract Factory 80
Functional Factory 83
Summary 85
Chapter 5: Prototype 87
Deep vs. Shallow Copying 87
ICloneable Is Bad 88
Deep Copying with a Special Interface 90
Deep Copying Objects 91
Duplication via Copy Construction 93
Serialization 94
Prototype Factory 96
Summary 98
Chapter 6: Singleton 100
Singleton by Convention 101
Classic Implementation 102
Lazy Loading 103
The Trouble with Singleton 104
Singletons and Inversion of Control 109
Monostate 110
Summary 111
Part III: Structural Patterns 112
Chapter 7: Adapter 114
Scenario 114
Adapter 116
Adapter Temporaries 118
The Problem with Hashing 122
Property Adapter (Surrogate) 125
Adapters in the .NET Framework 127
Summary 128
Chapter 8: Bridge 130
Conventional Bridge 130
Dynamic Prototyping Bridge 134
Summary 138
Chapter 9: Composite 139
Grouping Graphic Objects 139
Neural Networks 142
Shrink Wrapping the Composite 146
Summary 148
Chapter 10: Decorator 149
Custom String Builder 149
Adapter-Decorator 152
Multiple Inheritance 153
Dynamic Decorator Composition 157
Static Decorator 161
Functional Decorator 163
Summary 164
Chapter 11: Façade 166
Building a Trading Terminal 168
An Advanced Terminal 169
Where’s the Façade? 172
Summary 174
Chapter 12: Flyweight 175
Usernames 175
Text Formatting 178
Summary 182
Chapter 13: Proxy 183
Protection Proxy 183
Property Proxy 186
Virtual Proxy 189
Communication Proxy 192
Summary 195
Part IV: Behavioral Patterns 196
Chapter 14: Chain of Responsibility 197
Scenario 197
Method Chain 198
Broker Chain 202
Summary 207
Chapter 15: Command 208
Scenario 208
Implementing the Command Pattern 209
Undo Operations 211
Composite Commands 215
Functional Command 219
Queries and Command Query Separation 221
Summary 222
Chapter 16: Interpreter 223
Numeric Expression Evaluator 224
Lexing 225
Parsing 228
Using Lexer and Parser 232
Interpretation in the Functional Paradigm 232
Summary 237
Chapter 17: Iterator 239
Array-Backed Properties 240
Let’s Make an Iterator 243
Improved Iteration 247
Summary 249
Chapter 18: Mediator 250
Chat Room 250
Mediator with Events 255
Summary 260
Chapter 19: Memento 261
Bank Account 261
Undo and Redo 263
Summary 267
Chapter 20: Null Object 268
Scenario 268
Intrusive Approach 270
Null Object 270
Design Improvements 271
Null Object Virtual Proxy 272
Dynamic Null Object 273
Summary 275
Chapter 21: Observer 277
Weak Event Pattern 279
Property Observers 282
Dependency Problems 284
Event Streams 290
Observable Collections 295
Declarative Subscriptions 296
Summary 298
Chapter 22: State 299
State-Driven State Transitions 300
Handmade State Machine 303
State Machines with Stateless 307
Types, Actions, and Ignoring Transitions 307
Reentrancy Again 309
Hierarchical States 310
More Features 310
Summary 312
Chapter 23: Strategy 313
Dynamic Strategy 314
Static Strategy 317
Functional Strategy 319
Summary 320
Chapter 24: Template Method 321
Game Simulation 321
Functional Template Method 324
Summary 326
Chapter 25: Visitor 327
Intrusive Visitor 328
Reflective Printer 330
Functional Reflective Visitor 332
Improvements 333
What Is Dispatch? 334
Dynamic Visitor 336
Classic Visitor 338
Implementing an Additional Visitor 341
Acyclic Visitor 343
Functional Visitor 346
Summary 347
Index 348
Erscheint lt. Verlag | 11.5.2019 |
---|---|
Zusatzinfo | XV, 359 p. 4 illus. |
Sprache | englisch |
Themenwelt | Informatik ► Software Entwicklung ► Objektorientierung |
Schlagworte | C# • Design Patterns • F# • .NET • .NET development • Resharper • Reusable design patterns • Visual Studio |
ISBN-10 | 1-4842-4366-8 / 1484243668 |
ISBN-13 | 978-1-4842-4366-4 / 9781484243664 |
Haben Sie eine Frage zum Produkt? |
Größe: 3,3 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich