July 2001
Beginner to intermediate
368 pages
6h 52m
English
In Chapter 18, “The Template Method Pattern,” I ignored the issue of how to instantiate the database object required by my current context. I may not want to make the Client responsible for instantiating the database object. Instead, I might want to give that responsibility to the QueryTemplate class itself.
In Chapter 18, each derivation of the QueryTemplate was specialized for a particular database. Thus, I might want to make each derivation responsible for instantiating the database to which it corresponds. This would be true whether the QueryTemplate (and its derivations) was the only class using the database or not. Figure 19-1 shows this solution.