单身缺陷的详细解释 [英] Detail explanation of singleton drawbacks
问题描述
大家好,
我一直在读单身模式,它的优点和缺点。由于我是新手,我无法理解劣势的详细性质。如果可能的话,有人可以详细解释单身人士的缺点吗。
例如:
1.他们如何偏离单一责任原则(SRP)。 />
2.它隐藏了应用程序代码中的依赖关系。
提前致谢!!!
我尝试了什么:
我试过谷歌了解其中的缺点,但他们使用相同的条款没有任何例子。
Hi All,
I have been reading singleton pattern,it's advantages and disadvantages. Since I am new to this I am not able to understand the detailed nature of disadvantages. Can someone please explain in detail the disadvantages of singleton with any example if possible.
eg:
1. How do they deviate from Single Responsibility Principle(SRP).
2. It hides the dependency in the code of the application.
Thanks in advance!!!
What I have tried:
I have tried google to understand the disadvantages but everywhere they uses the same terms without any example.
推荐答案
我们甚至有一篇关于这个主题的文章: Singleton Pattern - 正面和负面的方面 [ ^ ]。但是,它没有显示示例。您也可以尝试使用 Google
来查找代码示例。
We have even an article on this very subject: Singleton Pattern – Positive and Negative Aspects[^]. It doesn't show examples, though. You may also try to use Google
for the purpose of finding code samples.
这篇关于单身缺陷的详细解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!