Search code examples
javascriptmoduledesign-patternsfacademediator

Modules + Fascade + Mediator combination in JavaScript


I've finished reading a great article on http://addyosmani.com/largescalejavascript/

This article explains how to combine modules, a facade, and a mediator together for a JavaScript application.

I can code what the article explains, but I don't understand why I need to use facade to access the mediator.

I think I can access the mediator directly from my modules.

Please advise me..

P.S: Is it a valid question here?


Solution

  • The reference material for that section, Pro Javascript Design Patterns, answers your question quite nicely when it says the following:

    Facades are never strictly necessary. The same tasks can be completed without them. This is an organizational pattern; it allows you to modify the interfaces of classes and objects to be more convenient to you.