Template Method Pattern
Definition-Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure

What’s template? It’s just a method; more specially, it’s a method that defines an algorithm as a set of steps. One or more of these steps is defined to be abstract and implemented by a subclass.
Hooked on Template Method
A hook is a method that is declared in the abstract class, but given an empty or default implementation. This give subclass the ability to “hook into” the algorithm at various points.
Example: JFrame,Applets
本文介绍了模板方法设计模式的基本概念,定义了一种算法的骨架,并允许子类在不改变算法结构的情况下重新定义某些步骤。文章还解释了钩子的概念及其在算法中的作用,并通过具体的例子进行说明。
1077

被折叠的 条评论
为什么被折叠?



