The Template Method
Skeleton algorithms with function injection.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Ritual Frameworks
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// GLEAM PATTERN //
pub type RitualHooks {
RitualHooks(
chant: fn() -> String,
sacrifice: fn() -> String,
)
}
pub fn perform_ritual(hooks: RitualHooks) -> String {
let part1 = hooks.chant()
let part2 = hooks.sacrifice()
part1 <> " and then " <> part2 <> " - The ritual is complete!"
}
The Template Method
Instead of overriding class methods, we provide a record of hook functions to a skeleton algorithm.
Runic Tags:
#evocation
#template-method
#gleam