-
-
Save carldanley/9187f369adcfc5c25e4f to your computer and use it in GitHub Desktop.
A simple example of the facade pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyModule = ( function( window, undefined ) { | |
// revealing module pattern ftw | |
function MyModule() { | |
function someMethod() { | |
alert( 'some method' ); | |
} | |
function someOtherMethod() { | |
alert( 'some other method' ); | |
} | |
// expose publicly available methods | |
return { | |
// in our normal revealing module pattern, we'd do the following: | |
someMethod : someMethod, | |
// in the facade pattern, we mask the internals so no one has direct access by doing this: | |
someMethod : function() { | |
someMethod(); | |
} | |
}; | |
} | |
} )( window ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@carldanley
Example call? Shouldn’t MyModule return something?