dimanche 1 février 2015

Difference between facade and module pattern


I was going through this article and i am confused on the diff between facade and module pattern.


http://ift.tt/1u9p9DJ



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 );


In both the ways we are actually calling the same function which is private. What big deal does facade provides?.





Aucun commentaire:

Enregistrer un commentaire