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.

http://code.google.com/p/pageforest/source/browse/appengine/static/src/js/namespace.js

My goals were to create something that felt very close to python
modules, and be natural in the JavaScript world.

I was also concern with out-of-order <script> inclusion, so namespaces
are created by this central library so inter-namespace references do
not rely on load order of scripts.

A typical pattern of use would be:

namespace.lookup('org.startpad.base').define(functionOnce(ns) {
       var util = namespace.util;
       var other = ns.lookup('org.startpad.other');

       function exportedFunction() {
             ...
             var foo = new other.ExternalClass();
              ....
       }

      ns.extend({'exportedFunction': exportedFunction});

Thanks!
Mike Koss

-- 
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