Template Method 在一个方法中实现一个算法,但是推迟定义算法中的某些步骤,从而使其他的类可以重新定义这些步骤

 一个经典实例 - 排序

自定义类
自定义排序类
客户代码
重构为模板
Machine类层次
Fuser
Mixer
MachinePlanner类层次
BasicPlanner
FuserPlanner
MixerPlanner
The Template Method Pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.
posted @ 2007-01-10 13:13  南守拥  阅读(232)  评论(1编辑  收藏  举报