There is a lot of discussion on this site about why singletons should be avoided but are there any cases where a singleton makes sense and is the best option?
An example where I think that a singleton is the best option is when implementing an Identity Map where you need to keep track of all models that have already been loaded from the database in your mapping layer. In this case it is important that the map is effectively global so that all client code uses the same instance of the map and they are all accessing the same list of loaded models. The simplest solution seems to be to implement the class as a singleton (or as static methods). Is this the best approach or is there another way?
Are there any other cases where it is OK to use a singleton or are they always bad?