The Factory Method Pattern in Michelson
Delegating the instantiation of arcane data structures to specialized entrypoints.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Stackmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MICHELSON PATTERN //
parameter (int %schema_id);
storage (list string);
code {
UNPAIR;
DUP;
PUSH int 1;
COMPARE; EQ;
IF {
DROP; PUSH string "Construct_Alpha";
} {
PUSH int 2;
COMPARE; EQ;
IF {
PUSH string "Construct_Beta";
} {
PUSH string "Construct_Omega";
}
};
CONS;
NIL operation; PAIR
}
Runic Tags:
#creational
#factory-method
#stack-based smart contracts
#michelson
#tezos