The Strategy Incantation
Hot-swapping combat algorithms dynamically within the ether.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Divination // Tactics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CLOJURE PATTERN //
(ns tekromancy.strategy)
;; Strategies are just first-class functions passed as arguments.
(defn aggressive-strategy [target]
(str "Casting Fireball directly at " target))
(defn stealth-strategy [target]
(str "Invisibly placing a trap near " target))
(defn execute-assassination [target strategy-fn]
(println "Initiating plan...")
(println (strategy-fn target)))
;; Usage:
;; (execute-assassination "The Baron" stealth-strategy)
Tactical logic must be modular. In a functional paradigm, the Strategy pattern disappears entirely, replaced by first-class functions. By simply passing the desired algorithmic rune as an argument to an executor, strategies are seamlessly injected and swapped at runtime.
Runic Tags:
#behavioral
#strategy
#clojure
#higher-order-functions