Template method lets abstract base class (this is the class to implement the algorithm) to implement invariant algorithm. The subclasses can redefine the algorithm when necessary. By this mechanism, we can reuse the code.
Normally, factory method is used by template to get instance of concrete subclass. Compared with template method, strategy uses delegation to vary the algorithm.
posted on 2012-12-20 23:23  #hanhui  阅读(113)  评论(0编辑  收藏  举报