What is the Template Method design pattern?

Answer

The Template Method pattern defines the skeleton of an algorithm in a base class, deferring some steps to subclasses. The base class method calls abstract or overridable "hook" methods in a fixed order. Subclasses fill in the specific steps without changing the overall algorithm structure. For example, a data mining framework might define: openFile()extractData()parseData()analyzeData()closeFile(). The base class implements the invariant steps; each concrete miner implements extractData() and parseData() for its specific format (CSV, XML, PDF). This is the foundation of the Hollywood Principle: "Don't call us, we'll call you."