Browse Java Design Patterns & Enterprise Application Architecture

Template Method Pattern

Use Template Method in Java when an algorithm skeleton should remain fixed while selected steps vary across subclasses.

Template Method is classic Java because the language and standard libraries have long used inheritance-based frameworks and skeletal base classes.

The pattern is strongest when:

  • the algorithm structure is stable
  • subclasses should vary only a few steps
  • inheritance is already a natural boundary

It is weaker in modern Java when composition or Strategy would communicate variation more directly.

In this section

Revised on Thursday, April 23, 2026