On 1/1/11, jemptymethod <jemptymet...@gmail.com> wrote:
> On Jan 1, 6:56 pm, RobG <rg...@iinet.net.au> wrote:
>>
>> The use of $ may be Ok in ECMA-5, but it still grates with me. If you
>> want to be able to safely access "private" variables and objects, you
>> need privileged functions that are available externally.
>
> Which my "module" code plainly provides
>
>>
>> >     return (function() {
>> >         $private.init();
>> >         $public = {};
Did you forget var somewhere?

I don't like to name identifiers based on their accessibility though I
see where you're going with this.

For an case where "state" variable is good, I have made good use of
"activeItem" idiom for things like "activeMenu", "activePanel", etc.
The identifier representing "activeItem" can be kept hidden in scope.

I suppose for more complicated actions, where the conditional logic of
checking object state is cluttering the program, the State pattern
might be used, keeping the State object hidden in Scope, allowing the
public interface to delegate to it. I don't have an example,
unfortunately.
--
Garrett

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to