Null Object模式研究  

Research on Null Object Pattern

在线阅读下载全文

作  者:吴清寿[1] 

机构地区:[1]武夷学院数学与计算机系,福建武夷山354300

出  处:《吉林师范大学学报(自然科学版)》2013年第1期120-122,共3页Journal of Jilin Normal University:Natural Science Edition

基  金:福建省教育厅科技基金项目(JA11265);武夷学院科研基金项目(X1201019)

摘  要:在许多面向对象的程序设计语言中,对象引用可能为空.在调用任何方法之前这些引用需要被检测以确保它们不为空.频繁的检测会引起代码的重复和系统的不稳定.Null Object模式能够用来解决这一问题.本文阐述了Null Object模式及其实现方式,针对空目标的单一实例化策略,给出了改进措施.Null Object模式对去除重复检测和减少空引用异常有较明显的效果.In many object-oriented languages , object references may be null. These references need to be checked to ensure they are not null before invoking any methods. Frequent checks lead to duplicated code and unstable system. The null object pattern can be used to solve this problem. This paper describes the null object pattern and its implementation. Furthermore,an improved measurement is given for the singleton-based instantiation strategy of null object. The null object pattern has obvious effect to remove duplicate checks and reduce null reference exception.

关 键 词:设计模式 NULL Object模式 代码坏味 SINGLETON模式 

分 类 号:TP311[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

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