Singleton
英文简单描述
Intent
Ensure a class only has one instance, and provide a global point for accessing to it.
How to
We make it a Singleton class in Java by adding a static getInstance operation and a static instance member.
We must also protect the constructor to prevent accidental instantiation.
Known Cases
Socket
Database Connection
UML
通常形式的单例:
子类化的单例实现:在运行时由配置文件来决定实例化哪个子类