Namespacing method?
Anastasia Cheetham
a.cheetham at utoronto.ca
Wed Jul 29 13:23:09 UTC 2009
On 29-Jul-09, at 7:07 AM, Aaron Zeckoski wrote:
> I am trying to figure out the best practice for JS namespacing and
> there is a ton of conflicting information out there.
>
> I have sorta settled on one of these:
> 1) From some of the websites on namespacing
> var AZ = function($) {
> ...
> }(jQuery);
>
> 2) From looking at the Fluid stuff as an example
> var AZ = AZ || {};
> (function($){
> ...
> )}(jQuery);
Aaron, one advantage of option #2 over option #1 is that it doesn't
tromp on anything that might already exist in the namespace - it
simply adds to it. This is part of why we use this technique in
Infusion, because we have multiple files that add things to the fluid
namespace.
--
Anastasia Cheetham a.cheetham at utoronto.ca
Software Designer, Fluid Project http://fluidproject.org
Adaptive Technology Resource Centre / University of Toronto
More information about the fluid-work
mailing list