The Template Method Scroll
Defining the skeleton of an algorithm, deferring some steps to subclasses.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Conjuration // Scaffolding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module TemplateMethod where
open import Data.String
record Operations : Set where
field
step1 : String
step2 : String
-- The template algorithm
runTemplate : Operations → String
runTemplate ops = Operations.step1 ops -- concatenated with step2 ideally
The Template Method Scroll
To summon a daemon, the ritual sequence is strict: light the cyber-candles, chant the IP address, break the seal. The Template Method Scroll defines the high-level steps while letting lower apprentices define the specific candle color.
The Dependent Runes
We achieve this by writing a core function runTemplate that requires a dictionary (Operations) of the missing steps.
Runic Tags:
#agda
#template-method
#scaffolding