O'Reilly logo

Learning Java Functional Programming by Richard M Reese

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

Implementing the template pattern

The template pattern is based around the idea that certain problems have structures that are reflected in a core method. This method uses the same set of operations to perform a task. This can be seen in a loading task where the basic steps to load a container is essentially the same whether the container is a box or a truck.

The steps are the same, such as prepared item to be loaded, but the specific preparation will vary depending on the container. A box may require that the item be wrapped in paper while the truck may require the application of a plastic wrap.

We will use a game engine to illustrate this template. The basic steps include:

  1. Rendering an image.
  2. Updating the game.
  3. Terminating the game when it is over. ...

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