C# Design Patterns: Singleton
This course will teach you when and how to apply the Singleton design pattern (and other ways to achieve the same behavior) to ensure certain classes only have a single instance within your application.
What you'll learn
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
- Introduction 2m
- Singleton Structure and Features 2m
- Demo: Naïve Singleton 5m
- Demo: Thread Safe Singleton 2m
- Analysis 1m
- Static Constructors and Singletons 1m
- Demo: Static Constructors and Singletons 3m
- Analysis 1m
- Lazy<T> and Singletons 1m
- Demo: Lazy<T> Singleton 2m
- Singletons are an Antipattern? 1m
- Singletons vs. Static Classes 1m
- Using Containers 4m
- Demo: Singleton Behavior with Containers 3m
- Analysis 1m
- Demo: Singleton Testing Considerations 3m
- Key Takeaways 1m