I'm not sure you understood my question - If all the private scope does is being run on construction, there's no reason to give it an object. the whole point of using a closure is that you can create "private" methods. The way I understand public/private concept is that you create a distinction between the interface and the inner behavior. but the interface itself can and should have access to the private interface internally. 2nd, at least wherever I've been programming, unless we use a singelton pattern (which is unnecessary in JS), the constructor is public and can usually be called again and again. IMO - this is not a bug. So what I don't understand is what use do you get from the 2nd private closure? why create a 2nd layer encapsulation? what good is it? so again - what advantages does this pattern have vs the original module pattern?
Lastly - I agree with the previous post that stated that UpperCase is for constructors, and your template clearly doesn't allow the use of new. On Sun, Jan 2, 2011 at 1:17 AM, jemptymethod <[email protected]> wrote: > > To answer: > > #1. The private methods *are* accessible. Just un-comment the > console.log, within private.init and you will see it is accessible. > This then sort of answers: > > #3: $public is wrapped with a closure so that, before return $public, > code can be executed, such as $private.init(). Indeed, I see this as > being a nice way to obviate a "temporal dependence", through use of > the "template method" pattern: initialization should occur before the > public interface is returned. > > Returning to your point #2, there is no constructor. Do you mean why > is the init method private? Well, there is no need for it to be > public, is there? Do you want users of the module to be able to call > init over and over again, whenever they please? -- 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]
