/**
 * Template Method is a behavioral design pattern that defines
 * the skeleton of an algorithm in the superclass but lets
 * subclasses override specific steps of the algorithm without
 * changing its structure.
 */ abstract class AbstractClass { protected beforeHook ( ) { return '' ; } protected baseStep ( ) { return 'AbstractClass.baseStep()' ; } protected abstract requiredStep ( ) ; public templateMethod ( ) { const result = [ ] ; result . push ( this . beforeHook ( ) || '' ) ; result . push ( this . baseStep ( ) || '' ) ; result . push ( this . requiredStep ( ) || '' ) ; return result ; } } export class ConcreteClass extends AbstractClass { protected requiredStep ( ) { return 'ConcreteClass.requiredStep()' ; } } export class ConcreteClassWithHook extends AbstractClass { protected beforeHook ( ) { return 'ConcreteClassWithHook.beforeHook()' ; } protected requiredStep ( ) { return 'ConcreteClassWithHook.requiredStep()' ; } }