Re:Enterprise Javascript is...
by dejv on Tuesday October 19, 2010 @08:23AM
(#1806848)
This one is best:
http://enterprise-js.com/16
[ Parent
| on HN ]
Usage shown in example is stupid.
However to present this approach as antipattern is also stupid.
If "enterprise" means even moderately big apps namespacing is the way to go.
Alas, that project mocks too much useful stuff to be liked by me.
Namespacing seems fine, but to torture the declaration syntax as shown on the site in order to get the Java-like com.domain.package.class.method() syntax is wrong. Just use underscores in the name rather than periods and use the syntax properly.
Not to mention, the next library you load will clobber the `com` variable.
Re:Enterprise Javascript is...
by latentflip on Tuesday October 19, 2010 @09:33AM
(#1807032)
That's the first example I got when loading the page, and that's exactly what I thought: for big projects namespacing seems sensible enough. So I thought the site was a collection of design patterns, rather than anti-patterns.
Left me very confused when the next example was declaring all your functions globally.
Still, two levels of namespaces are more than enough.
Feels like Google's Closure Library.
Closure doesn't do it that way, and the Closure Compiler will collapse the namespacing so that it doesn't result in runtime overhead.
Also, YUI.