Design Patterns in C# and .NET

Design Patterns in C# and .NET

English | MP4 | AVC 1280×720 | AAC 48KHz 2ch | 19.5 Hours | 4.45 GB

Discover the modern implementation of design patterns with C# and .NET

This course provides a comprehensive overview of Design Patterns in C# and .NET from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of C# and the .NET framework
  • Use of modern programming approaches: dependency injection, reactive programming and more
  • Use of modern developer tools such as ReSharper
  • Discussions of pattern variations and alternative approaches

This course provides an overview of all the Gang of Four (GoF) design patterns as outlined in their seminal book, together with modern-day variations, adjustments, discussions of intrinsic use of patterns in the language.

What are Design Patterns?

Design Patterns are reusable solutions to common programming problems. They were popularized with the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, John Vlissides, Ralph Johnson and Richard Helm (who are commonly known as a Gang of Four, hence the GoF acronym).

The original book was written using C++ and Smalltalk as examples, but since then, design patterns have been adapted to every programming language imaginable: C#, Java, PHP and even programming languages that aren’t strictly object-oriented, such as JavaScript.

The appeal of design patterns is immortal: we see them in libraries, some of them are intrinsic in programming languages, and you probably use them on a daily basis even if you don’t realize they are there.

What Patterns Does This Course Cover?

This course covers all the GoF design patterns. In fact, here’s the full list of what is covered:

  • SOLID Design Principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation
  • Principle and Dependency Inversion Principle
  • Creational Design Patterns: Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton
  • Structrural Design Patterns: Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy
  • Behavioral Design Patterns: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer,
  • State, Strategy, Template Method and Visitor

Who Is the Course For?

This course is for .NET/C# developers who want to see not just textbook examples of design patterns, but also the different variations and tricks that can be applied to implement design patterns in a modern way. For example, the introduction of the DLR allows us to use an ImpromptuObject, so that our DynamicObject exposes any interface we desire. This allows for dynamic programming, and many design patterns are presented in terms of their static and DLR-based variations.

Presentation Style

This course is presented as a (very large) series of live demonstrations being done in Microsoft Visual Studio. Most demos are single-file, so you can download the file attached to the lesson and run it in Visual Studio, Visual Studio Code, Rider or another IDE of your choice.

This course does not use UML class diagrams; all of demos are live coding. I use Visual Studio, various NuGet packages, R# unit test runner and even dotMemoryUnit.

What you’ll learn

  • Recognize and apply design patterns
  • Refactor existing designs to use design patterns
  • Reason about applicability and usability of design patterns
Table of Contents

Introduction
1 Introduction

The SOLID Design Principles
2 Overview
3 Single Responsibility Principle
4 Open-Closed Principle
5 Liskov Substitution Principle
6 Interface Segregation Principle
7 Dependency Inversion Principle
8 Summary

Builder
9 Gamma Categorization
10 Overview
11 Life Without Builder
12 Builder
13 Fluent Builder
14 Fluent Builder Inheritance with Recursive Generics
15 Functional Builder
16 Faceted Builder
17 Summary

Factories
18 Overview
19 Point Example
20 Factory Method
21 Asynchronous Factory Method
22 Factory
23 Inner Factory
24 Abstract Factory
25 Abstract Factory and OCP
26 Summary

Prototype
27 Overview
28 ICloneable is Bad
29 Copy Constructors
30 Explicit Deep Copy Interface
31 Prototype Inheritance
32 Copy Through Serialization
33 Summary

Singleton
34 Overview
35 Singleton Implementation
36 Testability Issues
37 Singleton in Dependency Injection
38 Monostate
39 Per-Thread Singleton
40 Ambient Context
41 Summary

Adapter
42 Overview
43 Vector Raster Demo
44 Adapter Caching
45 Generic Value Adapter
46 Adapter in Dependency Injection
47 Summary

Bridge
48 Overview
49 Bridge
50 Summary

Composite
51 Overview
52 Geometric Shapes
53 Neural Networks
54 Composite Specification
55 Summary

Decorator
56 Overview
57 Custom String Builder
58 Adapter-Decorator
59 Multiple Inheritance with Interfaces
60 Multiple Inheritance with Default Interface Members
61 Dynamic Decorator Composition
62 Detecting Decorator Cycles
63 Static Decorator Composition
64 Decorator in Dependency Injection
65 Summary

Façade
66 Overview
67 Façade
68 Summary

Flyweight
69 Overview
70 Repeating User Names
71 Text Formatting
72 Summary

Proxy
73 Overview
74 Protection Proxy
75 Property Proxy
76 Value Proxy
77 Composite Proxy SoA AoS
78 Composite Proxy with Array-Backed Properties
79 Dynamic Proxy for Logging
80 Proxy vs. Decorator
81 ViewModel
82 Bit Fragging
83 Summary

Chain of Responsibility
84 Overview
85 Command Query Separation
86 Method Chain
87 Broker Chain
88 Summary

Command
89 Overview
90 Command
91 Undo Operations
92 Composite Command
93 Summary

Interpreter
94 Overview
95 Handmade Interpreter Lexing
96 Handmade Interpreter Parsing
97 ANTLR
98 Summary

Iterator
99 Overview
100 Iterator Object
101 Iterator Method
102 Iterators and Duck Typing
103 Array-Backed Properties
104 Summary

Mediator
105 Overview
106 Chat Room
107 Event Broker
108 Introduction to MediatR
109 Summary

Memento
110 Overview
111 Memento
112 Undo and Redo
113 Memento for Interop
114 Summary

Null Object
115 Overview
116 Null Object
117 Dynamic Null Object
118 Summary

Observer
119 Overview
120 Observer via the ‘event’ Keyword
121 Weak Event Pattern
122 Observer via Special Interfaces
123 Observable Collections
124 Bidirectional Observer
125 Property Dependencies
126 Declarative Event Subscriptions with Interfaces
127 Summary

State
128 Overview
129 Classic Implementation
130 Handmade State Machine
131 Switch-Based State Machine
132 Switch Expressions
133 State Machine with Stateless
134 Summary

Strategy
135 Overview
136 Dynamic Strategy
137 Static Strategy
138 Equality and Comparison Strategies
139 Summary

Template Method
140 Overview
141 Template Method
142 Functional Template Method
143 Summary

Visitor
144 Overview
145 Intrusive Expression Printing
146 Reflection-Based Printing
147 Classic Visitor (Double Dispatch)
148 Dynamic Visitor via the DLR
149 Acyclic Visitor
150 Summary

Course Summary
151 Creational Paterns Summary
152 Structural Patterns Summary
153 Behavioral Patterns Summary
154 End of Course

Bonus Lectures Related Concepts
155 An ASCII C# String
156 Continuation Passing Style
157 Local Inversion of Control
158 DI Container and Event Broker Integration
159 Beyond the Elvis Operator
160 CQRS and Event Sourcing
161 Bonus Lecture Other Courses at a Discount

Bonus Lectures Functional Patterns in F#
162 Overview
163 Builder
164 Decorator
165 Factory
166 Interpreter
167 Strategy
168 Template Method
169 Summary