"I've used this pattern on projects ranging from 100 to 100,000 lines of code." - Bob Holt
- Cleaner approach for developers
- Supports private data
- Less clutter in the global namespace
- Localization of functions and variables through closures
- The syntax of our scripts are even more consistent
- Explicitly defined public methods and variables which lead to increased readability
- Private methods are unaccessible.Some people say that this leads to the inability of unit testing but more often than not, if you're questioning the integrity of a function, it should probably be engineered in such a fashion that exposes the utility of that function publicly, thus making it testable. Given the adaptation of the module pattern by jQuery and their everyday use of QUnit to automate testing, this bullet point isn't really relevant but still listed for documentation purposes.
- Private methods and functions lose extendability since they are unaccessible (see my comment in the previous bullet point).
- It's harder to patch public methods and variables that are referred to by something private.