Template Method パターンは、基本クラスでアルゴリズムの骨組みを定義し、サブクラスが全体的な構造を変えずに特定のステップを埋めることができるようにします。共通のプロセスを捉えながら、個々のステップのカスタマイズを可能にします。
Template Method パターンが行うこと
TEMPLATE METHOD → define an algorithm's overall STRUCTURE in a base method, with some STEPS
left for subclasses to implement:
→ the base class controls the overall flow (the "template")
→ subclasses override specific STEPS (the parts that vary)
→ the algorithm's structure is FIXED; the steps are customizable
→ "common process, customizable steps"
例
{
() {
data = .();
result = .(data);
.(result);
}
() { ; }
() { ; }
() { ; }
}
{ () {...} () {...} () {...} }
