Hermes Wiki

TemplateMethod

Defines the fixed skeleton of an algorithm in a base method, deferring specific steps to subclasses (or injected callbacks).

Why we need this / what value this brings

Keeps the overall sequence of steps in one place while letting individual steps vary, avoiding duplicated boilerplate around each variant's core logic.

When to use this

Several operations share the same overall sequence of steps but differ in one or two steps of that sequence.

How to use or implement this

Implement the fixed sequence in one method that calls out to overridable/injectable steps; in Python/TypeScript this is often a plain function taking step callbacks rather than a subclass hierarchy.

Research questions

  • Order/booking creation flows (validate → reserve → charge → notify) across different service types may already share this shape informally — worth checking whether the shared skeleton is explicit or duplicated per service type.
  • See Template Method Pattern — its "Common pitfall" section (a hook step silently violating an invariant several steps downstream) is the concrete failure mode to check for in any informally-shared skeleton found above.
Hermes Wiki