Possible Duplicate:
Singleton: How should it be used
I've read that singletons are bad. For instance, it makes the code hard to test. Are there any acceptable uses of singletons?
Sometimes you want one and only one connection to a database. Making your connector a singleton ensures that you will not spin up multiple connections.
精彩评论