Are there any downsides to the singleton pattern?
Possible Duplicates:
What is so bad about Singletons
Problems with Singleton Pattern
Are there any downsides to the singleton pattern? I heard this was an interview question and i am coming up short on what was meant.
imho, it's about the usage and nothing in the pattern itself is problematic
From Wikipedia:
Some consider it an anti-pattern , judging that it is overused, introduces unnecessary limitations in situations where a sole instance of a class is not actually required, and introduces global state into an application.
Personally, since I've started using Spring to auto-wire my application I've never had the need to write a singleton.
That's a very generic question, it really depends on your use cases. I'd cite the following:
上一篇: 这是用C ++创建单例类的正确方法吗?
下一篇: 单身模式有什么缺点吗?