Re:An introduction to the JavaScript Module Pattern
by ronaldj on Friday April 13, 2012 @11:57PM
(#3839842)
What if you want a clean API? What if you want the users of your code to be able to instantiate an instance and inspect that object in the console, seeing only the public methods and not having them get lost in a sea of private stuff?
[ Parent
| on HN ]
Re:An introduction to the JavaScript Module Pattern
by andybak on Saturday April 14, 2012 @04:45AM
(#3840297)
Hmmmm. The Python convention of semi-private methods starting with an underscore would do the trick.
I've been burnt in the past with using someone else's javascript code and finding out that something I needed to modify they hadn't deemed public for some weird reason.
Forking the code isn't the best pattern for code reuse.
Re:An introduction to the JavaScript Module Pattern
by bcrescimanno on Saturday April 14, 2012 @01:02AM
(#3839951)
FWIW, If you want instantiate-able objects, the module pattern is probably the wrong option in that case anyway.