摘要
为了解决模板方法模式中当延迟到子类中需扩展的算法步骤较多时,每扩展一个算法步骤,在新增的子类中不需要扩展的算法步骤也需要从原来类中拷贝一份这一问题,在扩展过程中引入策略模式,对模板方法模式进行改进。最后给出了一个考勤算法的案例。
The original algorithm steps of template method,which do not need to be extended,will be copied to a sub-class when a new algorithm step of template method is added to the sub-class.Aiming at the problem,a template method creating process was presented,which used the strategy pattern to reduce the unnecessary copies.Finally how to design an attendance algorithm with the improved pattern was discussed.
出处
《计算机应用》
CSCD
北大核心
2011年第A01期135-137,共3页
journal of Computer Applications
关键词
模板方法模式
策略模式
模式改进
单一职责
设计模式
template method pattern
strategy pattern
pattern improvement
single-responsibility
design pattern