Nov 15, 2013
The Singleton Pattern is frequently used to manage a limited resource that needs to managed by a single 'managing' entity. So, it could be a Document Manager, a dispatcher that routes requests to the least busy server, or as simple as an in-memory array of available payment processors (see example below).
Imagine that you have an ecommerce site selling books. When purchasing books your app has a choice of three payment processors, say PayPal, Authorize.net and PayFlow. Sometimes these processors are not available, so they need a single object that manages the availability of these resources. This is exactly the kind of scenario where you would use the Singleton pattern. If you had multiple instances of this object it would be inefficient and possibly create a mess.
So in this scenario you would create a singleton that maintains a list of the currently available payment processors. Each time a user checks out a shopping cart, it requests the service of the singleton to dispatch the processing of the credit card to an available processor. The availability of the payment processors changes over time and the singleton is the only one that is aware of these changes. This may sound complicated but in reality it is fairly simple.
Hope this gets you started.