🧱 B PRECURSOR DIFFICULTY: Apprentice Behavioral

The Strategy

Swapping out the foundational precursor algorithms at runtime.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// B PATTERN //
/* Strategies are raw function pointers passed into the executor */

strat_aggressive(target) {
    putchar('A'); putchar('T'); putchar('K');
}

strat_defensive(target) {
    putchar('D'); putchar('E'); putchar('F');
}

execute_tactic(strat, target) {
    /* Dynamic strategy invocation */
    strat(target);
}

battle_plan() {
    execute_tactic(strat_aggressive, 'E');
    execute_tactic(strat_defensive, 'M');
}
Runic Tags: #b #design-pattern #precursor #bell-labs-magic #untyped