您的位置:首页 > 其它

design pattern notes [5] - template method

2012-12-20 23:23 441 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: