?This is an interesting approach, kind of a mix between the YUI 2
namespacing scheme and the YUI 3 sandboxing scheme. I'm assuming that your
design goals are:
1. Create only one new global (namespace).
2. Do not create any additional properties on namespace (hence define() and
lookup()).
I think you achieve these goals elegantly. As a matter of preference, the
define() and lookup() methods seem like an extra layer of abstraction that
may not be necessary. For instance, you could pass an object into the
function that already contains the previously-loaded modules and allow
others to attach onto that (see: CommonJS export).
I'm interested in what happens after you've define all of your modules, as
in, how do I begin using the code I've defined?
-Nicholas
_____________________________________________________
Nicholas C. Zakas
Twitter: @slicknet
Blog: http://www.nczonline.net/
-----Original Message-----
From: Balázs Galambosi
Sent: Wednesday, January 19, 2011 3:59 PM
To: [email protected]
Subject: Re: [JSMentors] Feedback on namespace pattern implementation
2011/1/19 mckoss <[email protected]>:
I've been using a namespace pattern I developed and would love to get
feedback on my implementation/design. I know there is some wheel re-
invention here - I just have not yet found other patterns I like as
well.
There may be a reason for that.
My goals were to create something that felt very close to python
modules, and be natural in the JavaScript world. [examples]
This is where the problem starts.
The main issue here is that even the word namespace creates a false
illusion, that Javascript can be treated similar to other languages.
The hierarchically construction is quite appealing I can't argue that,
but it's very inefficent to use deeply nested chains of objects. They
come with a cost because of the way they work (property lookups).
The biggest problem here isn't the tools/libraries, but the people who
tend to misuse them.
Recommended reading: http://peter.michaux.ca/articles/javascript-namespacing
- Balázs
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]