
Software Design – The Template Method Pattern
In the last episode, we looked at abstracting algorithms. Now we examine the template method pattern and how it allows us to abstract steps of an algorithm. Thus, providing a template for implementation while leaving the freedom for subclasses to handle the details. The Template Method Pattern Defined As always, we will start with the “Gang of Four” intent to set the stage for our discussion. “Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.” This is a rather simple pattern to understand. We build a root or base class that lays out the steps of an algorithm. Then we leave some... Read more