📙
Design Pattern
  • Introduction
  • 0. About Design Pattern
  • 1. Singleton
  • 1.1 Eager Singleton (a.k.a Pessimistic Lock Singleton)
  • 1.2 Lazy Singleton (a.k.a Optimistic Lock Singleton)
  • 1.3 理解Singleton
  • 1.4 Cache Singleton
  • 1.5 Extend Singleton
  • 1.6 Double Check and Lock Singleton
  • 1.7 Lazy Initialization Holder Class
  • 1.8 Enum Singleton
  • 1.9 Conclusion
  • 2. Factory
  • 2.1 Simple Factory
  • 2.2 Factory
  • 2.3 Abstract Factory
  • 2.4 Conclusion
Powered by GitBook
On this page

Was this helpful?

1.9 Conclusion

Singleton的本質: 控制實例的數目

什麼時候選用singleton: 當需要控制一個類別的實例只能有一個, 而且client只能從一個全局存取點去存取該實例時, 就可以選用此模式.

Previous1.8 Enum SingletonNext2. Factory

Last updated 5 years ago

Was this helpful?