8.11.2011

About Patterns - Singleton

The Singleton pattern allows a developer to provide access application wide to a class that has only one instance. This pattern can be useful when designing a class that represents a single resource (such as a print spool).

A few items to consider with the Singleton pattern:

  • Control over how a client accesses a Singleton's instance is with the Singleton class
  • The namespace isn't polluted with global variables when the Singleton pattern is used
  • The number of instances is controlled in the Singleton class, so if at a later date it's determined more instances are required, it can be changed with less effort

More information including a sample implementation is available 
here.