Доки по разработке
This project is maintained by teniryte
Принципы
turnOnSystems, shutDown), не зная деталей конфигурации.Пример
class PlumbingSystem {
setPressure(v: number) {}
turnOn() {}
turnOff() {}
}
class ElectricalSystem {
setVoltage(v: number) {}
turnOn() {}
turnOff() {}
}
class House {
private plumbing = new PlumbingSystem();
private electrical = new ElectricalSystem();
turnOnSystems() {
this.electrical.setVoltage(120);
this.electrical.turnOn();
this.plumbing.setPressure(500);
this.plumbing.turnOn();
}
shutDown() {
this.plumbing.turnOff();
this.electrical.turnOff();
}
}
Практика