Facade
A single class that represents an entire subsystem.
EX:
interface Shape {
draw(): void;
}
public class Rectangle implements Shape {
draw() {
console.log("Rectangle::draw()");
}
}
public class Square implements Shape {
draw() {
console.log("Square::draw()");
}
}
public class Circle implements Shape {
draw() {
console.log("Circle::draw()");
}
}
class ShapeMaker {
private circle: Shape;
private rectangle: Shape;
private square: Shape;
constructor() {
circle = new Circle();
rectangle = new Rectangle();
square = new Square();
}
drawCircle(){
circle.draw();
}
drawRectangle(){
rectangle.draw();
}
drawSquare(){
square.draw();
}
}
const shapeMaker = new ShapeMaker();
shapeMaker.drawCircle();
shapeMaker.drawRectangle();
shapeMaker.drawSquare(); Last updated