⚙️ MICHELSON RUNE DIFFICULTY: Apprentice Behavioral

The Template Method Pattern in Michelson

Defining the invariant skeletal structure of an on-chain transaction workflow.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Enchantment // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter (int %process);
storage int;
code {
  UNPAIR;
  # Template Step 1: Immutable Pre-condition
  DUP;
  PUSH int 0;
  COMPARE; GT;
  IF {} { PUSH string "TemplateError: Input must be strictly positive"; FAILWITH; };
  
  # Template Step 2: Variable Computation (the "hole" filled by subclasses)
  # In Michelson, we hardcode the specific variant's logic here
  PUSH int 42;
  ADD;
  
  # Template Step 3: Immutable State Finalization
  SWAP; DROP;
  NIL operation; PAIR
}
Runic Tags: #behavioral #template-method #stack-based smart contracts #michelson #tezos