新的设计模式——数组工厂和数组原型模式  被引量:2

New design patterns:array factory and array prototype

在线阅读下载全文

作  者:彭世康 周逢权 

机构地区:[1]许昌许继软件技术有限公司技术中心

出  处:《计算机应用》2012年第A02期107-112,共6页journal of Computer Applications

摘  要:为了去除程序中的简单开关分支结构,提出了一种新的重构方法——"以数组取代类型码"重构手法。将这种新的重构方法用于重构简单工厂模式,就得到了一种新的软件设计模式——"数组工厂"模式。数组工厂模式适用于实例化某个具体类在软件执行流程的任意时刻只存在一个实体的对象;对于软件执行流程中可以同时存在多个实体的具体类对象的实例化工作,通过改造数组工厂模式,提出了"数组原型"模式。数组工厂和数组原型模式是两种结构优良的创建型设计模式,它们免除了简单工厂方法中的开关分支语句,具有优化代码结构、提高程序执行性能等优点,并且完全符合开放—封闭原则。A new design pattern named "array factory" was produced when the switch statements in simple factory method were refactored by "replace type code with array". Array factory pattern was applied to instantiate the object that has only one entity in software. Array prototype pattern was proposed for instantiating multiple objects of one class by improving array factory pattern. As two excellent creation patterns, array factory and array prototype patterns not only have almost all the benefits of simple factory pattern, but also eliminate the switch statements, optimize the structure of the program and improve the processing performance of the software, and they meet the open-closed principle.

关 键 词:设计模式 重构 开关分支语句 类型码 简单工厂 数组工厂 数组原型 

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

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

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