Flyweight
Efficiently share massive quantities of ethereal motes by externalizing their volatile state.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Illusion // Ethereal Optimization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// D PATTERN //
class MoteModel {
string elementalType;
this(string t) { elementalType = t; }
}
class MoteFactory {
private MoteModel[string] cache;
MoteModel getMote(string type) {
if (type !in cache) {
cache[type] = new MoteModel(type);
}
return cache[type];
}
}
Conserve memory during colossal conjurations.
Runic Tags:
#structural
#flyweight
#dlang
#memory-optimization