Zachary W. Huang
Idea: provide a unified, high-level interface to reduce complexity (typically involving multiple separate subsystems).
class SubsystemA {
doThing() {
console.log("A");
}
}
class SubsystemB {
doThing() {
console.log("B");
}
}
class SubsystemC {
doThing() {
console.log("C");
}
}
class Facade {
doThing() {
const thingA = new SubsystemA();
const thingB = new SubsystemB();
const thingC = new SubsystemC();
thingA.doThing();
thingB.doThing();
thingC.doThing();
}
}
function main() {
// the client does not have to know about each underlying subsystem
const facade = new Facade();
facade.doThing(); // "A B C"
}