First, it’s important to recognize scenarios where the Singleton pattern is useful and doesn’t just add unnecessary complexity to your code. The original Gang of Four text says you should consider using the Singleton pattern when:
You need to limit a class to a single instance and have that unique instance be accessible to clients through a global access point.
For example, your computer should only have one filesystem, in the same way that your body should only have one heart (for best performance). A global variable can take care of the accessibility, and in the case of C#, a static variable fits the bill nicely. When you put it all together, a singleton class is responsible for initializing, storing, and returning its own unique instance, as well as protecting against duplicate instance requests.
Figure 2.1 describes a game scenario where a manager script stores game state data and maybe some shared functionality.
In this...