我正在阅读这篇文章,我对facade
和module pattern
之间的差异感到困惑。
https://carldanley.com/js-facade-pattern/
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 );
我们实际上调用同一个私有函数的方式。门面提供的big deal
是什么?。