Object composition challenge (was: Using Object Literals as Classes)
lists at firefly.nu
Fri Mar 16 16:50:55 PDT 2012
On Sat, 17 Mar 2012 00:18:48 +0100, David Bruant <bruant.d at gmail.com>
> A Person knows one secret and has methods like .eat(), .walk()... There
> is no method in the Person interface to reveal the secret either
> directly or indirectly.
> A ComputerSavvyPerson is a Person, but has an additional
> .getMD5HashedSecret() method which returns the hashed secret.
> A StupidPerson is a person with a method .tellSecret()
For example, see <https://gist.github.com/2053624>. I don't see what's
with using closures for hiding variables, when necessary.
> This is a piece of cake with Java's protected. It is much convoluted in
> choice to expose their internals.
the internals rather than trying to hide them, similarly to how I think
idiomatic to assume the correct types of parameters rather than manually
checking their types (in many cases at least, especially for internal
functions). The "exposing all properties" flows well with how prototypal
inheritance works, but even disregarding that we also see "exposed
More information about the es-discuss