O'Reilly logo

Java™ Design Patterns: A Tutorial by James W. Cooper

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 25. The Template Pattern

In this chapter, we take up the Template pattern—a very simple pattern that you will discover you use all the time. Whenever you write a parent class and leave one or more of the methods to be implemented by derived classes, you are in essence using the Template pattern. This pattern formalizes the idea of defining an algorithm in a class, while leaving some of the details to be implemented in subclasses. In other words, if your base class is an abstract class, as often happens in these design patterns, you are using a simple form of the Template pattern. We note that Design Patterns refers to this as the Template Method Pattern, but we shorten the name in this chapter for convenience.

Motivation

Templates are so ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required