© Dmitri Nesteruk 2019
Dmitri NesterukDesign Patterns in .NEThttps://doi.org/10.1007/978-1-4842-4366-4_6

6. Singleton

Dmitri Nesteruk1 
(1)
St. Petersburg, c.St-Peterburg, Russia
 

When discussing which patterns to drop, we found that we still love them all. (Not really—I’m in favor of dropping Singleton. Its use is almost always a design smell.)

—Erich Gamma

The Singleton is the most hated design pattern in the (rather limited) history of design patterns. That said, however, it doesn’t mean you shouldn’t use the Singleton: a toilet brush is not the most pleasant device either, but sometimes it is simply necessary.

The Singleton design pattern grew out of a very simple idea that you should only have one instance of a particular component in your application. ...

Get Design Patterns in .NET: Reusable Approaches in C# and F# for Object-Oriented Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.