Maybe it's because of the lack of real examples, but I failed to understand
the need for so many closures:
1. Why do you create a list of private methods that even the inner module
cannot access?
2. Why make the constructor private?
3. Why wrap the public with a closure? why not simply return it? you don't
define anything within it

On Sat, Jan 1, 2011 at 7:48 AM, jemptymethod <[email protected]> wrote:

> 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]<jsmentors%[email protected]>
>



-- 
Arieh Glazer
אריה גלזר
052-5348-561
http://www.arieh.co.il
http://www.link-wd.co.il

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