Design Patterns in C#

Paths

Design Patterns in C#

Authors: Steve Smith, Filip Ekberg, Vladimir Khorikov, David Starr, Marc Gilbert, Steve Michelotti, Harrison Ferrone, David Berry

Design patterns have evolved from years of experience in resolving frequently encountered problems when writing object-oriented software. These patterns are templates that... Read more

Each of these courses will focus on a specific design pattern. By the end of each course, you will understand how the different components of the design pattern work together and how to use them in your own applications by demonstrating real-world practical step-by-step examples written in C#.

Pre-requisites

• Intermediate level of C# • Beginning level Visual Studio or Visual Studio Code

Behavioral

Behavioral design patterns are concerned with algorithms and the assignment of responsibilities between objects.

Design Patterns Overview

by Steve Smith

May 14, 2020 / 37m

37m

Start Course
Description

Design patterns help developers and teams solve problems using proven approaches. Patterns also enable teams to discuss design decisions using a richer, more descriptive language. In this course, Design Patterns Overview, you are introduced to the idea of patterns - how they're discovered, defined, and applied. First, you'll demonstrate a few useful patterns. Next, you'll discover how they can be combined and stacked to produce elegant, useful designs. Finally, you'll explore why you should spend time learning them. When you complete this course, you'll understand the role design patterns play in modern software development and you'll be ready to start mastering individual patterns that will make you more productive.

Table of contents
  1. Course Overview
  2. Design Patterns Overview

C# Design Patterns: Strategy

by Filip Ekberg

Dec 11, 2019 / 40m

40m

Start Course
Description

As your applications grow, you can often find areas which you want to extend. But due to lack of separation and coupling of concrete implementations this can sometimes be hard. An extremely common approach is to leverage interfaces to solve this, which brings us to the strategy pattern. In this course, C# Design Patterns: Strategy, you’ll learn foundational knowledge of the strategy pattern. First, you'll learn how to identify situations where this pattern is applicable. Next, you’ll discover how to easily refactor an application to leverage the strategy pattern, making the application extensible, testable, and easier to work with. Finally, you'll explore how to identify existing implementations of this pattern. When you’re finished with this course, you'll have the skills and knowledge of the strategy pattern needed to apply this in your solutions.

Table of contents
  1. Course Overview
  2. Strategy Pattern

C# Design Patterns: Singleton

by Steve Smith

May 4, 2020 / 33m

33m

Start Course
Description

In this course, C# Design Patterns: Singleton, you’ll learn to apply the Singleton design pattern to enforce single instance behavior for certain classes. First, you’ll explore the need for limiting the number of instances of certain classes. Next, you’ll discover how to use the Singleton pattern to enforce this behavior. Finally, you’ll learn how to apply other (potentially better) approaches to solving this same class of problems. When you’re finished with this course, you’ll have the skills and knowledge of the Singleton design pattern needed to address the need to ensure certain classes only have a single instance in your applications.

Table of contents
  1. Course Overview
  2. Applying the Singleton Pattern

C# Design Patterns: Command

by Filip Ekberg

Sep 24, 2019 / 26m

26m

Start Course
Description

Most, if not all software developers will need to be familiar with the command pattern and how commands are executed within applications in C# during their professional career. In this course, C# Design Patterns: Command, you'll cover everything you need to know to master this pattern and how to implement it into your C# applications. First, you'll uncover what the command pattern is and its characteristics. Next, you'll explore the benefits and tradeoffs when using the command pattern. Then, you'll implement the command pattern in new and existing solutions, as well as identify and leverage existing implementations. By the end of this course you’ll feel comfortable with implementing the command pattern in your applications. This will allow you to build reliable, more extensible and testable applications.

Table of contents
  1. Course Overview
  2. Command Pattern

C# Design Patterns: Bridge

by Vladimir Khorikov

Sep 10, 2020 / 31m

31m

Start Course
Description

Implementing a Bridge pattern may be difficult. In this course, C# Design Patterns: Bridge, you’ll learn how to implement the Bridge design pattern in C#. First, you’ll explore the drawbacks of the approach without the pattern. Next, you’ll discover how the Bridge pattern helps overcome these drawbacks. Finally, you’ll learn how to apply the Bridge pattern using composition instead of inheritance. When you’re finished with this course, you’ll have the skills and knowledge of the Bridge pattern needed to implement it in your own projects.

Table of contents
  1. Course Overview
  2. The Bridge Design Pattern

C# Design Patterns: Null Object

by David Starr

Dec 3, 2019 / 13m

13m

Start Course
Description

Stop null check overload in your code! In this course, C# Design Patterns: Null Object, you will gain the ability to apply a new way of managing null references in your team's codebase. First, you will learn about the source of nulls and how they came to be. Next, you will discover how most people code in defense of nulls, adding hundreds of lines of code inside significant codebases. Finally, you will explore how to use the Null Object pattern to stop these practices and depend on each object you receive by bringing non-null. When you’re finished with this course, you will have the skills and knowledge of null scenarios needed to apply the Null Object pattern.

Table of contents
  1. Course Overview
  2. Introduction

Specification Pattern in C#

by Vladimir Khorikov

Jun 27, 2017 / 1h 27m

1h 27m

Start Course
Description

Domain-driven design includes many established patterns and practices, and the specification pattern is one of them. In this course, Specification Pattern in C#, you'll learn how to properly implement the specification pattern in practice. First, you'll learn about the use cases for this pattern. Next, you'll explore common anti-patterns and pitfalls in this area. Finally, you'll wrap up the course by learning about how to maintain encapsulation, as well as how to combine different specifications together. By the end of this course, you'll have the necessary knowledge needed to apply this pattern in real-world projects.

Table of contents
  1. Course Overview
  2. Introduction
  3. Implementing the Specification Pattern the Naive Way
  4. Refactoring Towards Better Encapsulation

C# Design Patterns: State

by Marc Gilbert

Nov 9, 2019 / 43m

43m

Start Course
Description

Are you looking for a way to better manage state in your application? Are your methods loaded with complex condition logic that’s hard to follow, debug, and maintain? In this course, C# Design Patterns: State, you will learn a tried and true design pattern for handling any situation in which the behavior of entities in your application changes based on context or state. First, you will explore the concept of state including what it is and its implications for development. Next, you will review some traditional approaches to managing state like if-else statements and switches and examine their strengths and shortcomings. Then, you will be introduced to the State Design Pattern and learn why it exists and when to use it. Finally, you will get hands-on experience implementing the pattern in clean and concise way that you can use in any or all of your applications. When you’ve finished this course, you will have the skills and understanding required to implement this elegant solution to handling state in your applications.

Table of contents
  1. Course Overview
  2. The State Design Pattern

C# Design Patterns: Data Access Patterns

by Filip Ekberg

Apr 29, 2020 / 1h 23m

1h 23m

Start Course
Description

Most applications, if not all, need to work with some kind of data, a database, for example. Having a good strategy for how to decouple the specific data layer is crucial in order to make your application testable and maintainable. In this course, C# Design Patterns: Data Access Patterns, you’ll learn foundational knowledge of the different data access patterns. First, you'll learn how to implement the repository pattern and decouple parts of the application from the data layer. Then, you'll develop an understanding of where this pattern is applicable. Next, you’ll discover how to easily refactor an application to leverage the unit of work pattern, making the application even better. Finally, you'll explore how to leverage lazy loading to avoid unnecessary data being loaded into your application. When you’re finished with this course, you'll have the skills and knowledge of these different data access patterns and what is needed to apply this in your solutions.

Table of contents
  1. Course Overview
  2. Repository Pattern in C#
  3. Unit of Work Pattern in C#
  4. Lazy Load Pattern in C#

C# Design Patterns: Mediator

by Steve Michelotti

Dec 17, 2019 / 37m

37m

Start Course
Description

For developers looking to deepen their knowledge of design patterns, this code-focused course will fully introduce the mediator design pattern, which enables you to encapsulate object interaction with loose coupling. In this course, C# Design Patterns: Mediator, you will quickly get started with the mediator pattern. First, you will learn what the mediator pattern is and why you would want to use it. Next, you will discover how to implement your own mediator pattern. Finally, you will explore multiple variations of the mediator pattern in different contexts and different applications. When you are finished with this course, you will have the knowledge of the mediator pattern needed to implement and leverage the mediator pattern in your own C# applications.

Table of contents
  1. Course Overview
  2. Mediator Pattern

C# Design Patterns: Chain of Responsibility

by Filip Ekberg

Nov 6, 2019 / 40m

40m

Start Course
Description

Software developers need real-world implementation examples of the chain of responsibility pattern to better understand how they can be used in user validation, payment processing, and if/else situations. In this course, C# Design Patterns: Chain of Responsibility, you will gain foundational knowledge of the chain of responsibility pattern. First, you will learn how to identify situations where this pattern is applicable. Next, you will discover how easily this can be refactored into an object oriented approach, which not only is easier to maintain, but also more testable. Finally, you will explore how to identify existing implementations of this pattern. When you’re finished with this course, you will have the skills and knowledge of the chain of responsibility pattern needed to apply this in your solutions.

Table of contents
  1. Course Overview
  2. Chain of Responsibility Pattern

C# Design Patterns: Template Method

by Steve Smith

Jul 18, 2020 / 34m

34m

Start Course
Description

Design patterns are like individual tools you can add to your toolkit as a software developer. They don’t take long to introduce, but they can take a lot of practice to master. In this course, C# Design Patterns: Template Method, you’ll learn to apply the Template Method design pattern in your applications. First, you’ll explore an example of the kind of code where this pattern applies. Next, you’ll discover the Template Method pattern and how it’s structured. Finally, you’ll learn how to improve the original code by applying the pattern. When you’re finished with this course, you’ll have the skills and knowledge of the Template Method design pattern needed to apply it in your own software.

Table of contents
  1. Course Overview
  2. Applying the Template Method Pattern

C# Design Patterns: Visitor

by Harrison Ferrone

Apr 28, 2020 / 27m

27m

Start Course
Description

At the core of developing flexible, modular C# applications is a foundational knowledge of design patterns and their use cases. In this course, C# Design Patterns: Visitor, you’ll learn the skills you need to effectively leverage the Visitor design pattern in your own code. First, you’ll learn where the Visitor pattern fits into the overall design pattern canon and the problem it solves in software development. Next, you’ll dive into its building blocks, and finally, its correct implementation. When you’re finished with this course, you will have a firm understanding of the Visitor pattern and its effectiveness, as well as a concrete example of how to integrate it into your own projects. Software required: Visual Studio.

Table of contents
  1. Course Overview
  2. Implementing the Visitor Pattern

C# Design Patterns: Memento

by Steve Smith

Sep 2, 2020 / 32m

32m

Start Course
Description

Design patterns are like individual tools you can add to your toolkit as a software developer. They don’t take long to introduce, but they can take a lot of practice to master. In this course, C# Design Patterns: Memento, you’ll learn to apply the Memento pattern in your applications. First, you’ll explore the kinds of problems this pattern is meant to solve. Next, you’ll discover how the Memento problem can solve these problems. Finally, you’ll learn how to apply the pattern in real applications using C#. When you’re finished with this course, you’ll have the skills and knowledge of the memento pattern needed to use it in your applications.

Table of contents
  1. Course Overview
  2. Applying the Memento Pattern

Creational

Creational patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code.

C# Design Patterns: Builder

by Harrison Ferrone

Mar 5, 2020 / 28m

28m

Start Course
Description

At the core of developing flexible, modular C# applications is a foundational knowledge of design patterns and their use cases. In this course, C# Design Patterns: Builder, you’ll learn the skills you need to effectively leverage the Builder design pattern in your own code. First, you’ll learn where the Builder pattern fits into the overall design pattern canon. Next, you’ll dive into its building blocks. Finally, you'll get to see it's correct implementation. When you’re finished with this course, you'll have a firm understanding of the Builder pattern and its effectiveness, as well as a concrete example of how to integrate it into your own projects. Software required: Visual Studio.

Table of contents
  1. Course Overview
  2. Implementing the Builder Pattern

C# Design Patterns: Prototype

by Harrison Ferrone

Mar 5, 2020 / 24m

24m

Start Course
Description

At the core of developing flexible, modular C# applications is a foundational knowledge of design patterns and their use cases. In this course, C# Design Patterns: Prototype, you’ll learn the skills you need to effectively copy objects in your code. First, you’ll learn the theory and basic application of the Prototype pattern. Next, you’ll dive into its concrete implementation. Finally, the general use-cases in software development. When you’re finished with this course, you'll have a firm understanding of the Prototype pattern and its effectiveness, as well as a real-world example of how to integrate it into your own projects. Software required: Visual Studio.

Table of contents
  1. Course Overview
  2. Implementing the Prototype Pattern

Structural

Structural patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.

C# Design Patterns: Facade

by David Starr

Dec 12, 2019 / 13m

13m

Start Course
Description

Dealing with a big ball of mud class is annoying and potentially even dangerous. Having to orchestrate the use of many worker or service classes can be very complex, too, leading to code that is hard to read and difficult to manage. In this course, C# Design Patterns: Facade, you'll learn foundational knowledge and gain the ability to overcome these challenges with a simple to apply pattern. First, you'll learn about the need for the pattern in multiple scenarios. Next, you will discover how Facade addresses these problems you see in your code every day. Finally, you'll explore how to use Facade appropriately to help your code be more readable and maintainable to the delight of your team. When you’re finished with this course, you'll have the skills and knowledge of the Facade design pattern needed to use it to improve your code manageability, readability, and elegance.

Table of contents
  1. Course Overview
  2. Introduction Overview

C# Design Patterns: Decorator

by David Berry

Jan 2, 2020 / 32m

32m

Start Course
Description

The decorator design pattern allows you to dynamically add behavior to your classes without modifying the original class. This allows you to layer in new functionality to a class while keeping different concerns cleanly separated. The decorator pattern is especially useful for when you need to apply cross cutting concerns like logging, authorization, and caching, but can also be used to modify data passed to and from an object. Understanding how to apply the decorator pattern gives you a powerful tool when you need to add behavior to and extend the functionality of your classes.

Table of contents
  1. Course Overview
  2. The Decorator Pattern

C# Design Patterns: Composite

by Steve Michelotti

Nov 14, 2019 / 33m

33m

Start Course
Description

For developers looking to deepen their knowledge of design patterns, this code-focused course will fully introduce the composite design pattern, which enables you to manage tree structures in a uniform and concise way. In this course, C# Design Patterns: Composite, we’ll cover everything you need to know to quickly get started with the composite pattern. First, you’ll learn what the composite pattern is and why you’d want to use it. Next, you will discover how to implement your own composite pattern. Finally, you will explore existing composite patterns that exist in .NET and how to leverage them effectively. When you are finished with this course, you will have the knowledge of the composite pattern needed to implement and leverage the composite pattern in your own C# applications.

Table of contents
  1. Course Overview
  2. Composite Pattern

C# Design Patterns: Adapter

by Steve Smith

Jan 15, 2020 / 24m

24m

Start Course
Description

Design patterns help you solve common software problems with known, proven approaches. In this course, C# Design Patterns: Adapter, you will learn about the adapter design pattern - one of the most common and useful patterns you'll encounter. It's useful for the very common problem where you want to use a library or service provider, but its interface isn't compatible with what your current code expects. First, you will understand the problem the adapter pattern solves. Next, you will discover what software design principles apply to this pattern. Finally, you will explore how to apply this pattern and frequently used patterns. By the end of this course, you will know when and how to apply the adapter pattern in C#.

Table of contents
  1. Course Overview
  2. Applying the Adapter Pattern

C# Design Patterns: Flyweight

by Harrison Ferrone

Apr 28, 2020 / 35m

35m

Start Course
Description

At the core of developing flexible, modular C# applications is a foundational knowledge of design patterns and their use cases. In this course, C# Design Patterns: Flyweight, you’ll learn the skills you need to effectively leverage the Flyweight design pattern in your own code. First, you’ll learn where the Flyweight pattern fits into the overall design pattern canon and the problem it solves in software development. Next, you’ll dive into its building blocks, and finally, its correct implementation. When you’re finished with this course, you will have a firm understanding of the Flyweight pattern and its effectiveness, as well as a concrete example of how to integrate it into your own projects. Software required: Visual Studio.

Table of contents
  1. Course Overview
  2. Implementing the Flyweight Pattern

C# Design Patterns: Proxy

by Steve Smith

Apr 10, 2020 / 35m

35m

Start Course
Description

Design patterns help you solve common software problems with known, proven approaches. In this course, C# Design Patterns: Proxy, you will learn about four different variants of the Proxy pattern. The proxy design pattern is one of the most common and useful patterns you'll encounter, with uses for performance, security, and code organization. First, you will see the problem the proxy pattern solves and what software design principles apply. Next, you will discover how to apply the proxy pattern. Finally, you will learn about other similar design patterns. When you have completed this short course, you will have both a theoretical and real code understanding of applying the pattern in a variety of different scenarios using .NET and C#.

Table of contents
  1. Course Overview
  2. Applying the Proxy Pattern