nav emailalert searchbtn searchbox tablepage yinyongbenwen piczone journalimg journalInfo journalinfonormal searchdiv searchzone qikanlogo popupnotification paper paperNew
2017, 09, v.33;No.293 68-70+74
单例设计模式的研究与实现
基金项目(Foundation): 咸阳师范学院专项科研计划项目(2014XSYK038)
邮箱(Email):
DOI:
发布时间: 2017-09-20
出版时间: 2017-09-20
移动端阅读
摘要:

单例设计模式能够保证某个类的对象在内存中只有唯一的实例,该实例易于被外界访问并节约系统资源。分析了单例模式的角色构成和创建要点,分别从饿汉式、懒汉式、双重验证式、类加载式、枚举式等5个方面阐述了单例模式的实现过程,总结了5种形式的优缺点和应用场景。将单例模式应用到JDBC数据库开发中,设计了一个JDBC工具类,为单例模式的实际应用提供了一定的参考。

Abstract:

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 JDBC tool class is designed.It provides a reference for the practical application of the singleton pattern.

基本信息:

中图分类号:TP311.52

引用信息:

[1]葛萌,欧阳宏基,陈伟.单例设计模式的研究与实现[J].微型电脑应用,2017,33(09):68-70+74.

基金信息:

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

发布时间:

2017-09-20

出版时间:

2017-09-20

检 索 高级检索

引用

GB/T 7714-2015 格式引文
MLA格式引文
APA格式引文