🐹 GO RUNE DIFFICULTY: Adept Creational

The Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EXECUTABLE GO PATTERN //
package prototype

// Prototype interface
type Cloneable interface {
	Clone() Cloneable
}

// ConcretePrototype
type ShadowDouble struct {
	Health int
	Weapon string
}

func (s *ShadowDouble) Clone() Cloneable {
	// Perform a deep copy (or shallow, if adequate for the spell)
	return &ShadowDouble{
		Health: s.Health,
		Weapon: s.Weapon,
	}
}

The Prototype

Why invoke the costly ether when you can copy what already exists? The Prototype pattern allows a master of illusions to cast a Shadow Double by simply duplicating a pre-compiled template. This spell drastically reduces mana expenditure in high-frequency clone spawning, copying the exact state memory to the newly formed simulacrum.

Runic Tags: #Creational #Illusion #Go