Possible Duplicate:
What is so bad about Singletons?
Singleton Design Pattern: Pitfalls
我听过很多这样的说法,但没有找到确切的理由。
Avoid the singleton anti-pattern and replace it with DI.
但是,为什么呢?
最佳答案
有状态的单例更难进行单元测试。
我使用无状态单例,我认为这没有问题。
由于单例可以实现接口(interface),因此可以使用依赖注入(inject)来传递它们(并且应该在可能的情况下这样传递)
关于c# - 单例反模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12075993/