Thanks for the response.

On Jun 21, 10:41 am, "David Marrs" <[email protected]> wrote:
> You're not overwriting the namespace, but extending it, so you wouldn't want 
> to fail if an object is already there. It just means that you can separate 
> your code out into separate files in a reliable way.
>
> You can also load those modules asyncronously if you wish.
>
> On 21 Jun 2011 13:46, Philip Schweiger &lt;[email protected]&gt; wrote:
>
> Ok, that makes a bit more sense. I can see that working when you have
>
> complex code with different dependencies loading at different times. I
>
> think it makes a bit less sense when dealing with smaller, self-
>
> contained modules as opposed to namespaces, though - in that case, I
>
> still think it would make more sense to throw an error. So I suppose
>
> it comes down to the use case - are you working with objects as a
>
> large namespace, or objects as a self-contained module.
>
> Thanks.
>
> On Jun 20, 10:25&nbsp;am, Nick Morgan &lt;[email protected]&gt; wrote:
>
> &gt; Let's say you have YAHOO.util.search and YAHOO.util.dom (making these
>
> &gt; up). Both rely on a YAHOO.util namespace, but you can't assume that
>
> &gt; that namespace has already been created. So you check to see if
>
> &gt; YAHOO.util exists, and if not, make it. Otherwise you use the
>
> &gt; pre-existing namespace.
>
> &gt;
>
> &gt; On 20 June 2011 15:11, Philip Schweiger &lt;[email protected]&gt; wrote:
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt;
>
> &gt; &gt; In reading about the JavaScript namespacing or module patterns, I
>
> &gt; &gt; often see a step taken to avoid overwriting an existing object. For
>
> &gt; &gt; instance, at Eric Miragla's description of the module pattern 
> (http://
>
> &gt; &gt;www.yuiblog.com/blog/2007/06/12/module-pattern/), he mentions that 
> the
>
> &gt; &gt; YAHOO.namespace() method "assigns an empty object myProject as a
>
> &gt; &gt; member of YAHOO (but doesn’t overwrite myProject if it already
>
> &gt; &gt; exists)."
>
> &gt;
>
> &gt; &gt; I don't understand the utility of this - wouldn't it be better to
>
> &gt; &gt; throw an error instead? Presumably, if you are trying to assign a
>
> &gt; &gt; namespace that already exists, you were not aware of the prior
>
> &gt; &gt; existence of that namespace, so that is a coding error that you 
> should
>
> &gt; &gt; be made aware of, and a signal to the script to stop further
>
> &gt; &gt; execution. If you DID already know of the existence of this 
> namespace,
>
> &gt; &gt; I'd think you'd want a sort of "extend" method, NOT an assignment
>
> &gt; &gt; method. In neither case does it make sense that the script should 
> just
>
> &gt; &gt; assume you knew what you were doing here and continue on. Am I 
> missing
>
> &gt; &gt; something?
>
> &gt;
>
> &gt; &gt; Thanks!
>
> &gt;
>
> &gt; &gt; --
>
> &gt; &gt; To view archived discussions from the original JSMentors Mailman 
> list: http://www.mail-archive.com/[email protected]/
>
> &gt;
>
> &gt; &gt; To search via a non-Google archive, visit 
> here:http://www.mail-archive.com/[email protected]/
>
> &gt;
>
> &gt; &gt; To unsubscribe from this group, send email to
>
> &gt; &gt; [email protected]
>
> &gt;
>
> &gt; --
>
> &gt; Nick Morganhttp://skilldrick.co.uk
>
> &gt; @skilldrick
>
> --
>
> 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]

Reply via email to