gof-template-method

Installation
SKILL.md

One-line summary

Define the skeleton of an algorithm in a base method, deferring some steps to subclasses — letting subclasses redefine certain steps without changing the algorithm's structure.

When to use this skill

  • Two or more classes follow the same overall procedure but differ in one or two steps (Beck's "Coffee and Tea both brew" example).
  • A workflow has a fixed sequence but specific stages vary by use case (e.g., a parsing pipeline where the tokenize step differs per format).
  • Cross-cutting framework hooks: a base class provides lifecycle methods, subclasses override the ones they care about (Spring's JdbcTemplate, JUnit's setUp / tearDown).

When NOT to use this skill

  • The variation is the algorithm itself, not steps within a skeleton — that's gof-strategy.
  • Only one step varies and the variation is small — a function parameter or lambda is simpler than a subclass.
  • The base class becomes an inheritance choke point that prevents the subclass from doing anything outside the template — that's a sign the abstraction is too rigid.

Core content

A TemplateMethod is a (typically final or non-overridable) method on the base class that calls a sequence of steps, some implemented in the base, others abstract or "hook" methods that subclasses override.

Installs
19
GitHub Stars
1
First Seen
Jul 13, 2026
gof-template-method — yonatankarp/software-design-skills