🗼 EIFFEL CONTRACT DIFFICULTY: Apprentice Creational

The Factory Method Incantation

Delegating familiar summoning to specialized subclasses.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Summoning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EIFFEL PATTERN //
deferred class
    SUMMONER

feature -- Factory Method

    summon_familiar: FAMILIAR
        deferred
        ensure
            summoned_entity_exists: Result /= Void
        end

feature -- Operation

    execute_summoning
        local
            fam: FAMILIAR
        do
            fam := summon_familiar
            fam.serve
        end
end

The Factory Method delegates the exact nature of the summoned entity to the specific subclass of the summoner, bound by rigid postconditions.

Runic Tags: #creational #factory-method #eiffel