单例设计模式的研究与实现  被引量:3

Research and Implementation of Singleton Design Pattern

在线阅读下载全文

作  者:葛萌 欧阳宏基 陈伟 

机构地区:[1]咸阳师范学院计算机学院,陕西咸阳712000

出  处:《微型电脑应用》2017年第9期68-70,74,共4页Microcomputer Applications

基  金:咸阳师范学院专项科研计划项目(2014XSYK038)

摘  要:单例设计模式能够保证某个类的对象在内存中只有唯一的实例,该实例易于被外界访问并节约系统资源。分析了单例模式的角色构成和创建要点,分别从饿汉式、懒汉式、双重验证式、类加载式、枚举式等5个方面阐述了单例模式的实现过程,总结了5种形式的优缺点和应用场景。将单例模式应用到JDBC数据库开发中,设计了一个JDBC工具类,为单例模式的实际应用提供了一定的参考。The singleton design pattern ensures that one class has only one object instance in memory, the instance is easy to be accessed by the outside world and save system resources. The role composition and the key points of the singleton pattern are analyzed,the implementation process of the singleton pattern is described from five aspects of hungry type, lazy type, double authentication type, class loading type and enumeration type. Then it summarizes the advantages and disadvantages of those five types, and their application scenarios. The singleton pattern is applied to the database development with JDBC, and a JD- BC tool class is designed. It provides a reference for the practical application of the singleton pattern.

关 键 词:单例模式 设计模式 JDBC 类加载 枚举 

分 类 号:TP391.78[自动化与计算机技术—计算机应用技术]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象