Re:Design patterns explained in Javascript
by funksta on Thursday July 14, 2011 @01:26PM
(#2763982)
My understanding (and the article reflects this) is that the "module pattern" generally refers to a function that is executed immediately after definition; ie: var module = (function() { ... })().
I'm guessing you're referring to Crockford's pattern (IIRC he calls it a "functional constructor" in JS:tGP), which is generally the same, but the function is instead executed when an object is instantiated with it.
It's a small distinction, but your drawbacks don't apply to the module pattern as I understand it, since the function is only executed once.
I'm guessing you're referring to Crockford's pattern (IIRC he calls it a "functional constructor" in JS:tGP), which is generally the same, but the function is instead executed when an object is instantiated with it.
It's a small distinction, but your drawbacks don't apply to the module pattern as I understand it, since the function is only executed once.