You are here

Template Method Pattern: Expressing Invariant Behavior in terms of Variant Behaviors

15 January, 2016 - 09:02
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at
Note: The code for the classes AFrame, FrameA, FrameAB, and FrameAC are available in the glossary.

The code for AFrame is an example of what is called the Template Method Pattern. This design pattern is used to expresses an invariant and concrete behavior that consists of calls to one or more abstract methods. An abstract method represents a variant behavior. In other words, the template design pattern is a means to express an invariant behavior in terms of variant behaviors. We shall see this pattern used again in expressing sorting algorithms.