Those who use it will find that they often have to write the same code each time they want to create a different Singleton class.
他们会发现每次他们要创建一个不同的单例类的时候,都不得不写同样得代码。
The only other method (set in italics) in the class is used to get a reference to the singleton and to create it if it is not yet instantiated.
该类中仅剩的另一个方法(用斜体标识)用于获取该单件的一个引用,如果尚未实例化则创建它。
Likewise, with a singleton implemented as single instance, you leave open the possibility of altering the class to create more instances in the future.
同时,如果使用创建单实例的方法实现单例模式,单例类还具有创建多个实例的变通能力。
应用推荐