Template Method design pattern
01
Standardize the skeleton of an algorithm in a base class “template” method
Common implementations of individual steps are defined in the base class
Steps requiring peculiar implementations are “placeholders” in base class
Derived classes can override placeholder methods
Derived classes can override implemented methods
Derived classes can override and “call back to” base class methods
02
abstract class Generalization {
// 1. Standardize the skeleton of an algorithm in a "template" method
public void findSolution() {
stepOne();
stepTwo();
stepThr();
stepFor();
}
// 2. Common implementations of individual steps are defined in base class
protected void ste
↧