How much sugar do classes need?

P T Withington ptw at pobox.com
Mon Nov 24 07:37:40 PST 2008


On 2008-11-22, at 23:54EST, Peter Michaux wrote:

>>
>>        let privClassVar = 1;
>>        const privClassConst = -1;
>
> So members are private by default? I like that and it is consistent
> with a style of JavaScript OOP popular today. In the wiki page members
> are public by default which is as dangerous as implied globals (i.e. a
> missing "var") in ES3.

My 2p:  I feel just the opposite.  Conflating classes (OOP) with  
access control is a big mistake in my book, a big mistake made by Java  
that we ought to learn from.  It leads you to either write really huge  
classes, or to have to 'decorate' all your classes with public  
declarations.  Access control should have its own orthogonal mechanism  
-- modules or packages that can consist of one or more classes and can  
gather the access control declarations in one spot so they are easily  
analyzed, as opposed to scattering them over all the component classes.


More information about the Es-discuss mailing list