The Template Method: Ritual Skeleton
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Rituals
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class_name CraftingRitual extends RefCounted
# The Template Method
func perform_ritual() -> void:
prepare_materials()
chant_incantation()
finish_item()
func prepare_materials() -> void:
push_error("Must be overridden")
func chant_incantation() -> void:
push_error("Must be overridden")
func finish_item() -> void:
print("Item crafted successfully.")
# Concrete subclass
class_name PotionCrafting extends CraftingRitual
func prepare_materials() -> void:
print("Gathering herbs and water.")
func chant_incantation() -> void:
print("Whispering the healing words.")
Some arcane processes must follow a strict, invariable sequence, yet the specifics of each step vary wildly. The Template Method establishes the inviolable skeleton of the ritual. Subclasses weave their own unique magic into the designated hooks, ensuring the foundational laws of the operation are never broken.
Runic Tags:
#godot
#gdscript
#template
#inheritance