Please consider the following template.  Sure its a little verbose,
but Uncle Bob declare comments to be failures, so I'm trying to
obviate such failure with the identifiers $private and $public.  Also
the nested closures allow all state to be hidden with $private, and
for code (e.g. $private.init()) to be executed within the same scope
from which the ($public) interface is returned.

Feedback appreciated; I merely intend on opening a discussion.  Some
or many may disagree with this approach.  But is there anything
outright wrong about it?

var Module = (function() {
    var $private = (function() {
        var $state = {};
        var $private = {};

        $private.state = function() {return $state};
        $private.init = function() {
                                    //console.log('$private.init invoked');
                                };

        return $private;
    })();

    return (function() {
        $private.init();
        $public = {};
                                return $public;
    })();

})();

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