The purpose of the facade pattern is to conceal the underlying complexity of the code by using an anonymous function as an extra layer. Internal subroutines are never exposed but rather invoked through a facade which makes this pattern secure in that it never exposes anything to the developers working with it. The facade pattern is both extremely interesting and very useful for adding an extra layer of security to your already minified code. This pattern is extremely useful when coupled with the revealing module pattern.
- Enhances security for your web application
- Works well in combination with other patterns
- Easy to implement
- Makes it easy to patch internals
- Provides a simpler public interface
- Proven useful for other major libraries such as jQuery
There aren’t any real drawbacks as it provides a unified interface to a set of interfaces in a subsystem. As a result, you aren’t forced to make any unwanted compromises, thus a win-win. One possible note worth mentioning is that a developer must decide whether the implicit cost of implementation is really worth the abstraction (though this is generally a small footprint).
|1 2 3 4 5 6 7 8 9 10 11 12||
The above is a basic example of the facade pattern.
|1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29||
The above is a more advanced version of the facade pattern that adds security to internal methods.