I was skimming the blog C0DE517E, and I ran across an interesting post on why singletons are bad. I love singletons, and I try to use them all over the place. Well... at least I did...
There were two Google Tech Talks I found from the blog and I wanted to share the insight I learned from them with you.
The first one I watched was “The Clean Code Talks - 'Global State and Singletons'”. It really kind of blew my mind. The video actually plays right along with what you are thinking. If you don't already agree with the idea of no singletons, then I strongly suggest you watch this video:
I took away several different things, but I thought I would post the most important one here. You should only put things into a constructor for which that object is directly dependent, but conversely, always put all things that object is directly dependent on in the constructor. This means that your class should usually not new any object and should never access any singletons inside the constructor. Your object should not hide dependencies as this makes them hard to understand.
The speaker seems be talking from a testing perspective, but I can see how these things can help keep your code understandable and more stable. Basically he seems to throw everything I've done in my current graphics engine into the garbage, but I feel like I've learned quite a bit. I'm always trying to clean my code and make it more understandable, and to my detriment, I'm maybe even a little OCD about this.
You may still have some questions or not fully understand after watching the above video, so I found another video that really helps to explain in more detail how to clean your code. It is done by the same speaker, Misko Hevery. Here is “The Clean Code Talks - 'Don't Look For Things!'”: