38.11. Framework Design with the Template Method Pattern
The next section describes some of the essential design features of the Database Mappers, which are a central part of the PFW. These design features are based on the Template Method GoF design pattern [GHJV95].[2] This pattern is at the heart of framework design,[3] and is familiar to most OO programmers by practice if not by name.
[2] This pattern is unrelated to C++ templates. It describes the template of an algorithm.
[3] More specifically, of whitebox frameworks . These are usually class hierarchy and subclassing-oriented frameworks that require the user to know something about their design and structure; hence, whitebox.
The idea is to define a method (the Template Method) in a superclass that defines the skeleton of an algorithm, with its varying and unvarying parts. The Template Method invokes other methods, some of which are methods that may be overridden in a subclass. Thus, subclasses can override the varying methods in order to add their own unique behavior at points of variability (see Figure 38.6).
Figure 38.6. Template Method pattern in a GUI framework.
[View full size image]