摘要
单例模式是一种Web开发中广泛应用的设计模式,应用该模式的类只能在类体内部实例化本类唯一的实例对象,并通过该类的静态成员方法提供给整个应用程序,起到全局共享的作用.该种模式的应用可以降低应用程序的资源耗费、提高运行效率,但当系统任务繁重或一个实例对象难以胜任时,就显得捉襟见肘,多例模式作为单例模式的扩展,通过生成有限个实例对象,既能避免类体本身实例对象的无序生成,又很好的解决了单个实例对象所不能完成的任务,可以说是单例模式优点的延续和扩展.
The singleton pattem is a design pattem used for Web development,the class instantiate the only object inside the class applied the singleton pattern, and provide the object to the whole application through the static methods of the class, play a shared global role. Application of this kind of mode can reduce the application's resource consumption and improve operational efficiency. But it is difficult when competency system task or an instance exists only. Multiple instances model is as an extension of singleton pattern. It can avoid disorderly generating the class body object through generating a finite object instance.It is a very good solution to finish the task unfinished by the only object also. This model can be said to be continuation and expansion of the singleton pattern.
出处
《计算机系统应用》
2014年第5期218-221,共4页
Computer Systems & Applications
关键词
模式
单例
多例
变量
patter
singleton
multiple instances
variables