C#: Design Patterns Part 1

C#: Design Patterns Part 1

2h 8mIntermediate2020-10-15

Authors

Richard Goforth

Richard Goforth

Software Architect and Consultant

Course details

Design patterns are an important part of programming. Rather than programming solutions to every issue from scratch, developers can implement these patterns that solve common problems. In this course, instructor Richard Goforth explains the purpose and effective use of key design patterns in C#. Richard begins by discussing why design patterns make sense, what they are, and how they are grouped and categorized. He then provides an overview of the creational, behavioral, and structural Gang of Four design patterns and how they are applied in C# and .NET. Next, he takes a deeper dive into the Iterator, Factory Method, and Adapter patterns, providing hands-on challenges that help you master the application of these patterns in your own code.

Skills covered

Software DesignAdvancedPythonProgramming LanguagesOpen SourceSoftware Development

Concepts

Introduction

  • Object-oriented design patterns in C#
  • What you should know
  • Review of terms
  • Using the exercise files and installing .NET SDK

Defining Software Design Patterns

  • Object-oriented programming
  • What isn't OOP for design patterns
  • C#, OOP, and design patterns
  • What are design patterns
  • Why do you need design patterns
  • A short history of design patterns
  • Categories of design patterns
  • Challenge - Design patterns outside of software
  • Solution - Design patterns outside of software

Get Started with Design Patterns

  • Using software design patterns
  • Software design pattern drawbacks
  • Overview of the creational patterns for C#
  • Overview of the structural patterns for C#
  • Overview of the behavioral patterns for C#

The Iterator Pattern

  • Iterator pattern definition
  • Explicit iterator implementation in C# for generated data
  • Combining iterators in C# with LINQ
  • Challenge - Simultaneous iterators
  • Solution - Simultaneous iterators

The Factory Method Pattern

  • Factory Method pattern definition
  • Factory Method pattern to choose the implementation of an action dynamically
  • Factory Method design pattern for unit testing
  • Challenge - Factory Method with dependency injection
  • Solution - Factory Method with dependency injection

The Adapter Pattern

  • Adapter pattern definition
  • Adapter in C# - Adapt FileStream to ILogger
  • Adapter pattern for ViewModel mapping
  • Challenge - Class adapter vs. object adapter
  • Solution - Class adapter vs. object adapter

Conclusion

  • Next steps
80,000 Toman