检索规则说明:AND代表“并且”;OR代表“或者”;NOT代表“不包含”;(注意必须大写,运算符两边需空一格)
检 索 范 例 :范例一: (K=图书馆学 OR K=情报学) AND A=范并思 范例二:J=计算机应用与软件 AND (U=C++ OR U=Basic) NOT M=Visual
机构地区:[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[自动化与计算机技术—计算机软件与理论]
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在链接到云南高校图书馆文献保障联盟下载...
云南高校图书馆联盟文献共享服务平台 版权所有©
您的IP:216.73.216.145