Addy references two variations to the Module pattern:
It states that globals can be passed in as arguments to the module’s anonymous function, but if they are already in the global scope why do they need to be passed into the function? Can they not already be accessed inside the function without being passed in?
Am I ccrrect in saying that the only variation to the original pattern is that the module object and it’s propeties/methods are created privately, and then returned by the anonymous function? Effectively, exporting (some of) our private scope.
Thanks in advance for your help!
Oh, I’ve wanted to read that – how is it? I have a dozen books I can’t get to. Programming gets in the way!
On 1), I don’t know specifically. But this approach facilitates “dependency injection” whereby you can pass in whatever you want without the module knowing about the outside lexical scope. This is great for unit testing, for example, and aids in decoupling. But that’s just my observation on this…
On 2), that sounds correct.
Thank you for your response @jboxman, I think I understand the idea behind Import Mixins now.
I wanted to research design patterns as I understand that a lot of newbie developers focus quite heavily on syntax before understanding the fundamentals of programming. Feels like there is an awful lot to learn, but I’m enjoying the challenge!