- 3
- 0
- 约1.25万字
- 约 4页
- 2018-08-19 发布于天津
- 举报
单例模式及其扩展在Web开发中的应用分析①
计 算 机 系 统 应 用 2014 年 第 23 卷 第 5 期
①
单例模式及其扩展在Web 开发中的应用分析
刘耀钦
(郧阳师范高等专科学校 计算机科学系, 十堰 442700)
摘 要: 单例模式是一种 Web 开发中广泛应用的设计模式, 应用该模式的类只能在类体内部实例化本类唯一的
实例对象, 并通过该类的静态成员方法提供给整个应用程序, 起到全局共享的作用. 该种模式的应用可以降低应
用程序的资源耗费、提高运行效率, 但当系统任务繁重或一个实例对象难以胜任时, 就显得捉襟见肘, 多例模式
作为单例模式的扩展, 通过生成有限个实例对象, 既能避免类体本身实例对象的无序生成, 又很好的解决了单个
实例对象所不能完成的任务, 可以说是单例模式优点的延续和扩展.
关键词: 模式; 单例; 多例; 变量
Application Analysis of Singleton Pattern and its Extension in Web Development
LIU Yao-Qin
(Department of Computer Science of Yunyang Teachers’ College, Shiyan 442700, China)
Abstract: The singleton pattern is a design pattern 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.
Key words: patter; singleton; multiple instances; variables
1 引言 力资源管理系统和学生报到注册系统时遇到的相当苦
随着 Web 开发中模式设计的不断发展与进步, 基 恼和困惑的问题. 单例模式及其扩展的应用很好的解
于单例模式及其扩展的应用已得到广泛使用, 诸如数 决了这个问题, 该模式中, 数据库连接对象是唯一的,
据库连接池、线程池、缓存等都会用到单例模式,
原创力文档

文档评论(0)