41. What is the Singleton design pattern?
Singleton is a class that only allows creating a single instance of itselt.
單例設計模式是一個類,它只允許創建自己的單個實例。
構造函數防止他在單例類以外的地方被調用。
使用情景:need a single object resposible for some job that is shared by the whole application.
What is a globl state? public?
Why is singleton considered an anti pattern?
What is the difference between the singleton design pattern and the application singleton?應用程序單例模式:不同位置使用的單個對象,不強制執行其單例。