本文已被:浏览 1061次 下载 1847次
Received:November 05, 2019 Revised:November 28, 2019
Received:November 05, 2019 Revised:November 28, 2019
中文摘要: 面向对象的程序设计越来越追求程序的可复用性和灵活性, 对于经验较少的程序设计者直接得到具有良好复用性和灵活性的程序是具有一定难度的, 软件设计模式就是提取面向对象程序设计者的经验, 并对其进行总结. 模板方法模式中父类定义一个算法的框架, 用模板方法规定算法的执行步骤, 将可变的步骤延迟到子类实现, 每一种不同的实现都需要定义一个新的子类, 系统会越来越庞大, 系统的可维护性以及可读性越来越差. 因此将抽象工厂模式嵌入到模板方法模式形成一个复合模式, 复合模式的设计核心是为每一个延迟到子类的可变的步骤提供一个创建对象的接口, 该接口对一个完整的产品族进行了定义. 复合模式既保证了算法结构的稳定性, 又分离了具体的实现类, 增强了程序的健壮性、可复用性以及灵活性.
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.
文章编号: 中图分类号: 文献标志码:
基金项目:河南省交通运输厅重点项目(220024140173)
引用文本:
林欣欣,郭元术,运杰伦,苏欣欣.基于模板方法与抽象工厂的复合模式.计算机系统应用,2020,29(6):218-223
LIN Xin-Xin,GUO Yuan-Shu,YUN Jie-Lun,SU Xin-Xin.Compound Pattern on Template Method and Abstract Factory.COMPUTER SYSTEMS APPLICATIONS,2020,29(6):218-223
林欣欣,郭元术,运杰伦,苏欣欣.基于模板方法与抽象工厂的复合模式.计算机系统应用,2020,29(6):218-223
LIN Xin-Xin,GUO Yuan-Shu,YUN Jie-Lun,SU Xin-Xin.Compound Pattern on Template Method and Abstract Factory.COMPUTER SYSTEMS APPLICATIONS,2020,29(6):218-223