In reading about the JavaScript namespacing or module patterns, I often see a step taken to avoid overwriting an existing object. For instance, at Eric Miragla's description of the module pattern (http:// www.yuiblog.com/blog/2007/06/12/module-pattern/), he mentions that the YAHOO.namespace() method "assigns an empty object myProject as a member of YAHOO (but doesn’t overwrite myProject if it already exists)."
I don't understand the utility of this - wouldn't it be better to throw an error instead? Presumably, if you are trying to assign a namespace that already exists, you were not aware of the prior existence of that namespace, so that is a coding error that you should be made aware of, and a signal to the script to stop further execution. If you DID already know of the existence of this namespace, I'd think you'd want a sort of "extend" method, NOT an assignment method. In neither case does it make sense that the script should just assume you knew what you were doing here and continue on. Am I missing something? Thanks! -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com