Singleton class implementing an interface

Possible Duplicate:
What is so bad about Singletons?

One of the drawbacks of using Singleton, as widely discussed in this stackoverflow question is that they hide the class dependencies in the code. However, we can make a singleton implement an interface while still obeying the two rules of singleton: single instance and global scope.
Why is Singleton still said to hide dependencies?


Hiding dependencies means there is no visible link from your code to the singleton, as the singleton can be called from anywhere. Having the singleton implementing an interface doesn't change the problem.

链接地址: http://www.djcxy.com/p/82166.html

上一篇: 单身模式有什么缺点吗?

下一篇: 实现接口的单例类