Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Facade Pattern

Avatar for Rahul Sharma Rahul Sharma
September 29, 2017

Facade Pattern

Avatar for Rahul Sharma

Rahul Sharma

September 29, 2017

More Decks by Rahul Sharma

Other Decks in Programming

Transcript

  1. Façade Pattern Creational Pattern Structural Pattern Behavioral Pattern Abstract Adapter

    Command Builder Bridge Interpreter Factory Composite Mediator Prototype Facade Memento Singleton . . . . . The famous 23 design patterns of OOP.
  2. Façade Pattern Creational Pattern Structural Pattern Behavioral Pattern Abstract Adapter

    Command Builder Bridge Interpreter Factory Composite Mediator Prototype Facade Memento Singleton . . . . . Façade = A single class that represents an entire subsystem
  3. Façade Pattern • This pattern involves a single class which

    provides simplified methods required by client and delegates calls to methods of existing system classes.
  4. When to use Façade? • A simple interface is required

    to access a complex system • A system is very complex or difficult to understand • An entry point is needed to each level of layered software • The abstractions and implementations of a subsystem are tightly coupled.
  5. jQuery $.get(url, data, callback, dataType); $.ajax({ url: url, data: data,

    dataType: dataType }).done(callback); // Functions to create xhrs function createStandardXHR() { try { return new window.XMLHttpRequest(); } catch( e ) {} } function createActiveXHR() { try { return new window.ActiveXObject( "Microsoft.XMLHTTP" ); } catch( e ) {} } // Create the request object jQuery.ajaxSettings.xhr = window.ActiveXObject ? /* Microsoft failed to properly * implement the XMLHttpRequest in IE7 (can't request local files), * so we use the ActiveXObject when it is available * Additionally XMLHttpRequest can be disabled in IE7/IE8 so * we need a fallback. */ function() { return !this.isLocal && createStandardXHR() || createActiveXHR(); } : // For all other browsers, use the standard XMLHttpRequest object createStandardXHR; ...