Singletons are NOT an anti-pattern

I get annoyed sometimes when beautiful patterns like the Null Object Pattern get dismissed out of hand because they use singletons. There is nothing wrong with singletons in themselves, the problem, and the anti-pattern, is when people use singletons to store global state. A good singleton, like the Null Object, keeps no (mutable) state and as such behaves as a constant, not a variable.

Leave a Reply

Your email address will not be published. Required fields are marked *