基于模板方法与抽象工厂的复合模式
作者:
作者单位:

作者简介:

通讯作者:

中图分类号:

基金项目:

河南省交通运输厅重点项目(220024140173)


Compound Pattern on Template Method and Abstract Factory
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 增强出版
  • |
  • 文章评论
    摘要:

    面向对象的程序设计越来越追求程序的可复用性和灵活性, 对于经验较少的程序设计者直接得到具有良好复用性和灵活性的程序是具有一定难度的, 软件设计模式就是提取面向对象程序设计者的经验, 并对其进行总结. 模板方法模式中父类定义一个算法的框架, 用模板方法规定算法的执行步骤, 将可变的步骤延迟到子类实现, 每一种不同的实现都需要定义一个新的子类, 系统会越来越庞大, 系统的可维护性以及可读性越来越差. 因此将抽象工厂模式嵌入到模板方法模式形成一个复合模式, 复合模式的设计核心是为每一个延迟到子类的可变的步骤提供一个创建对象的接口, 该接口对一个完整的产品族进行了定义. 复合模式既保证了算法结构的稳定性, 又分离了具体的实现类, 增强了程序的健壮性、可复用性以及灵活性.

    Abstract:

    Object-oriented programming is increasingly pursuing the reusability and flexibility of the program. It is difficult for programmers with less experience to obtain reusable and flexible programs directly. The software design pattern is to extract the experience of object-oriented programmers, and then to summarize them. In the template method pattern, the parent class defines an algorithm framework, uses the template method to specify the execution steps of the algorithm, and delays the variable steps to the subclass implementation. Each different implementation needs to define a new subclass. The system will be larger with maintainability and readability. Therefore, embedding the abstract factory pattern into the template method pattern forms a composite pattern. The core of the composite pattern design is to provide an interface for creating objects for each variable step that is delayed to the subclass. The interface is for a complete definition of product family. The composite mode not only ensures the stability of the algorithm structure, but also separates the specific implementation class, which enhances the robustness, reusability and flexibility of the program.

    参考文献
    相似文献
    引证文献
引用本文

林欣欣,郭元术,运杰伦,苏欣欣.基于模板方法与抽象工厂的复合模式.计算机系统应用,2020,29(6):218-223

复制
分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2019-11-05
  • 最后修改日期:2019-11-28
  • 录用日期:
  • 在线发布日期: 2020-06-12
  • 出版日期:
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京海淀区中关村南四街4号 中科院软件园区 7号楼305房间,邮政编码:100190
电话:010-62661041 传真: Email:csa (a) iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号