This pattern involves a single class which provides simplified methods required by client and delegates calls to methods O F Existing system classes.
/** * Design patterns-facade Pattern * https://www.tutorialspoint.com/design_pattern/facade_pattern.htm */// Interfacefunction shape () {}shape.prototype.draw = function () {throw "Shape::d Raw () must be overridden";};/ /Implements Shapefunction Rectangle () {shape.call (this);} Rectangle.prototype = new Shape (); Rectangle.prototype.draw = function () {Console.log ("Rectangle::d Raw ()")};/ /Implements Shapefunction Square () {shape.call (this);} Square.prototype = new Shape (); Square.prototype.draw = function () {Console.log ("Square::d Raw ()")};/ /Implements Shapefunction Circle () {shape.call (this);} Circle.prototype = new Shape (); Circle.prototype.draw = function () {Console.log ("Circle::d Raw ()");}; function Shapemaker () {this.circle = new circle (); This.rectangle = new Rectangle (); This.square = new Square ();} ShapeMaker.prototype.drawCircle = function () {This.circle.draw ();}; ShapeMaker.prototype.drawRectangle = function () {This.rectangle.draw ();}; Shapemaker.Prototype.drawsquare = function () {This.square.draw ();}; function Facadepatterndemo () {this.shapemaker = new Shapemaker ();} FacadePatternDemo.prototype.main = function () {this.shapeMaker.drawCircle (); This.shapeMaker.drawRectangle (); This.shapeMaker.drawSquare ();}; var demo = new Facadepatterndemo ();d emo.main ();
Output:
Circle::d Raw ()
Rectangle::d Raw ()
Square::d Raw ()
JavaScript [Design Patterns-facade Pattern]