⚙️ ISABELLE RUNE DIFFICULTY: Apprentice Creational

The Factory Method

Define an interface for creating an artifact, but let subclasses or specific implementations decide which artifact to manifest.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Manifestation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ISABELLE PATTERN //
theory FactoryMethod
  imports Main
begin

datatype artifact = Wand | Staff | Orb

locale artifact_factory =
  fixes create_artifact :: "unit \<Rightarrow> artifact"

interpretation wand_factory: artifact_factory "\<lambda>_. Wand"
  by unfold_locales

interpretation staff_factory: artifact_factory "\<lambda>_. Staff"
  by unfold_locales

end
Runic Tags: #isabelle #hol #conjuration #design-patterns