The template method pattern involves defining the common structure of an algorithm, and then allowing subclasses to change or redefine some portion of the algorithm without changing the complete structure. In other words, the template method pattern defines a function in a set of operations, allowing subclasses to redefine a few steps without altering the complete structure.
In this pattern, the base class declares the generic procedure with placeholders and lets subclasses provide the specific implementations of those placeholders while keeping the overall structure unchanged.
Let's understand the template method pattern with an example. Suppose you are writing a program to take row data, validate it, format it, ...