The singleton pattern is a fully paid up member of the GoF 's patterns book , but it lately seems rather orphaned by the developer world.
(单例模式是GoF的模式书的全额付费成员,但最近似乎被开发人员世界孤立了。)
I still use quite a lot of singletons, especially for factory classes , and while you have to be a bit careful about multithreading issues (like any class actually), I fail to see why they are so awful. (我仍然使用很多单例,尤其是对于工厂类 ,尽管您必须对多线程问题(实际上是任何类)有所注意,但我看不出它们为什么如此糟糕。)
Stack Overflow especially seems to assume that everyone agrees that Singletons are evil.
(堆栈溢出似乎特别假设每个人都同意Singletons是邪恶的。)
Why? (为什么?)
Please support your answers with " facts, references, or specific expertise "
(请以“ 事实,参考或特定专业知识 ”支持您的回答)
ask by community wiki translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…