🏛️ DELPHI ORACLE DIFFICULTY: Apprentice Creational

Factory Method Wards

Entrusting the exact type of enchantment to the sub-classes of the magical order.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Sub-school of Deferral
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DELPHI PATTERN //
unit FactoryMethodWards;

interface

type
  IVCLWard = interface
    procedure Activate;
  end;

  TWardWeaver = class abstract
  protected
    function ConjureWard: IVCLWard; virtual; abstract;
  public
    procedure CastProtection;
  end;

  TShadowWard = class(TInterfacedObject, IVCLWard)
  public
    procedure Activate;
  end;

  TShadowWeaver = class(TWardWeaver)
  protected
    function ConjureWard: IVCLWard; override;
  end;

implementation

uses System.SysUtils;

procedure TShadowWard.Activate;
begin
  Writeln('A shadow ward wraps around the form components.');
end;

procedure TWardWeaver.CastProtection;
var
  Ward: IVCLWard;
begin
  Ward := ConjureWard;
  Writeln('Weaving pre-incantation signs...');
  Ward.Activate;
  Writeln('Ward sealed.');
end;

function TShadowWeaver.ConjureWard: IVCLWard;
begin
  Result := TShadowWard.Create;
end;

end.

The ancient Weaver initiates the ritual, but only the specific lineage (the subclass) dictates which IVCLWard is brought forth to guard the realm.

Runic Tags: #delphi #gof #creational #conjuration #factory-method