The Proxy of the Progenitor
Control access to forbidden knowledge using closures.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Abjuration // Access Control
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
signature GRIMOIRE = sig
val readForbiddenSecrets : string -> string
end
structure TrueGrimoire : GRIMOIRE = struct
fun readForbiddenSecrets user =
"Behold the cosmic truths, " ^ user ^ "!"
end
structure GrimoireProxy : GRIMOIRE = struct
fun readForbiddenSecrets user =
if user = "Archmage" then
TrueGrimoire.readForbiddenSecrets user
else
"Access Denied. You are not ready for this knowledge."
end
val attempt1 = GrimoireProxy.readForbiddenSecrets "Apprentice"
val attempt2 = GrimoireProxy.readForbiddenSecrets "Archmage"
The Proxy pattern intercepts calls to a real subject. In SML, we implement the same signature as the true structure, placing protective wards in the Proxy structure. Whether for access control, lazy initialization, or logging, the Proxy allows an Archmage to transparently manage how and when the underlying functions of the true system are evaluated.
Runic Tags:
#access control
#wrapper
#lazy evaluation