On Fri, Mar 16, 2012 at 6:20 PM, Domenic Denicola <
[email protected]> wrote:

>
>  On Mar 16, 2012, at 18:12, "Rick Waldron" <[email protected]> wrote:
>
>
>
> On Fri, Mar 16, 2012 at 6:04 PM, David Bruant <[email protected]> wrote:
>
>> Le 16/03/2012 23:00, Rick Waldron a écrit :
>>
>> On Fri, Mar 16, 2012 at 5:12 PM, Domenic Denicola <
>> [email protected]> wrote:
>>
>>>  Just to contribute to this... er... fun-thread...
>>>
>>> My team uses the closure pattern for our "classes" (i.e. no prototype
>>> methods at all), since we value encapsulation. I can't imagine we're alone.
>>>
>>
>>  For my own curiosity, can you point me to some examples where you are
>> strategically avoiding the use of the prototype pattern?
>>
>>  When he needs actual encapsulation.
>> Unfortunately, methods on prototype require to have properties that are
>> public.
>>
>
>  If you avoid prototype methods, all your attributes and private methods
>> can be shared by public method scopes.
>>
>
>  Sorry, I don't subscribe to this as an adequate argument against
> prototypes. jQuery has a whole lot of hidden, private functions and data -
> using an IIFE. Ultimately, the developer makes the decision to write well
> encapsulated code - prototype or closure pattern should have no bearing.
>
>  Rick
>
>
>
>>
>>
>> David
>>
>
>
> That only works for singleton modules, not multi-instance classes.
>


Multi-instance as in many instances created from a "class"? Every call to
jQuery or its alias $ actually produces a new, unique object instance from
a real constructor.

The example you gave produces a constructor that wraps a handful of
instance method definitions along with several function declarations -
which I'm arguing could just as easily be outside of that function
declaration, but inside of an IIFE.

Rick



>
>  WeakMaps and private names both provide solutions for associating
> private data to an instance, without abandoning prototypes, but that brings
> me back to my original point: class sugar must make such association easier
> than manual `Name.create()` usage, on par with the ease of the closure
> pattern.
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to