The Golem Crafter
Piece together complex asynchronous constructs step-by-step.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Transmutation // Construct Animation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DART PATTERN //
class Golem {
String? core;
String? shell;
String? motiveForce;
@override
String toString() => 'Golem(Core: $core, Shell: $shell, Force: $motiveForce)';
}
class GolemBuilder {
final Golem _golem = Golem();
GolemBuilder bindCore(String core) {
_golem.core = core;
return this;
}
GolemBuilder forgeShell(String shell) {
_golem.shell = shell;
return this;
}
GolemBuilder channelForce(String force) {
_golem.motiveForce = force;
return this;
}
Golem awaken() {
if (_golem.core == null || _golem.shell == null) {
throw Exception('Incomplete construct!');
}
return _golem;
}
}
void main() {
final ironGolem = GolemBuilder()
.bindCore('Magma Heart')
.forgeShell('Iron Plating')
.channelForce('Steam')
.awaken();
print(ironGolem);
}
When bringing complex constructs to life, chanting all the syllables at once risks mispronunciation and fiery doom. The Builder pattern allows a spellcaster to chant incantations step-by-step, chaining methods fluently before finally invoking the awaken() command.
Runic Tags:
#dart
#builder
#transmuter
#fluent-api