The project I'm working on has an enormous JS file that I didn't want
to add to. I wanted to access some of the methods defined, so I
created an adapter file that would load "after" (minfied + combined)
the main file.

Here is how the original would look:
var APP = APP || {};
APP = {
        stuff : {
                doStuff : function(){},
                doStuffAgain : function(){}
        },
        moreStuff : {
                doMoreStuff : function(){}
        }
};


In order to access it's methods, I returned it as an object like this:
var APP = APP || {};
APP = (function() {
        return {
                stuff : {
                        doStuff : function() {
                        },
                        doStuffAgain : function() {
                        }
                },
                moreStuff : {
                        doMoreStuff : function() {
                        }
                }
                // etc
        };
})();

It seems to work fine. I have access to everything I need in my
adapter. However, there were never any tests written, so I'm not 100%
sure EVERYTHING will work.
Are there any obvious downsides in doing something like this?

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