Strategy in ReasonML
Passing higher-order runes to determine algorithmic fate.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactical
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// REASON PATTERN //
let strike = (damageStrategy, base) => damageStrategy(base);
let critStrategy = (x) => x * 2;
let poisonStrategy = (x) => x + 5;
let finalDmg = strike(critStrategy, 10);
Functions are first-class citizens. The Strategy pattern is simply passing a specific behavior function into a generic executor.
Runic Tags:
#reason
#strategy
#behavioral