🥞 FORTH STACK DIFFICULTY: Adept Behavioral

Template Method (Forth)

Lay the skeletal framework and let the subclasses flesh it out.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Necromancy // Skeleton-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FORTH PATTERN //
\ Skeleton-Weaving: The Template Method
\ A rigid skeleton word calling deferred implementation steps.

DEFER PREPARE-INGREDIENTS
DEFER BREW-POTION

\ The Template Word
: CRAFT-ELIXIR ( -- )
  ." Heating cauldron..." CR
  PREPARE-INGREDIENTS
  BREW-POTION
  ." Elixir bottled." CR ;

: PREP-HEAL ( -- ) ." Grinding root." CR ;
: BREW-HEAL ( -- ) ." Simmering until red." CR ;

\ Usage:
\ ' PREP-HEAL IS PREPARE-INGREDIENTS
\ ' BREW-HEAL IS BREW-POTION
\ CRAFT-ELIXIR

The Template Method establishes the unchangeable skeleton of a ritual. By defining the high-level control flow with deferred sub-steps, the master necromancer ensures the ritual order is obeyed, leaving only the specific flesh and sinew to be provided by later bindings.

Runic Tags: #behavioral #template-method #forth #skeletons