Classical inheritance is obsolete

Eric Elliott eric at ericleads.com
Sun Jun 30 19:03:09 PDT 2013


"That skeleton doesn’t even have to be a hierarchy, it could be a set of
classes."

Then you don't need `extends` or `super`.

- Eric


On Sun, Jun 30, 2013 at 4:42 PM, Axel Rauschmayer <axel at rauschma.de> wrote:

> To me, single inheritance has always been the skeleton on which I hang
> multiply inherited pieces. That skeleton doesn’t even have to be a
> hierarchy, it could be a set of classes.
> Maybe you simply need to write a mixin or trait library that works well
> with ES6 classes?
>
> Axel
>
> On Jul 1, 2013, at 0:22 , Eric Elliott <eric at ericleads.com> wrote:
>
> "Honest question: how can this problem not be solved via ES6 classes plus
> mixins? The original hierarchy already feels wrong. Why not create a
> super-class Animal, with sub-classes Human, Ape, Bird, Bee, Fish, Whale
> plus the mixins Walking, Flying, Swimming?"
>
> I completely agree with you, but in the real world we don't always have
> the benefit of knowing future requirements enough to create the correct
> design from the outset. Maybe the design was correct in the beginning
> (immagine a classification of species, instead of a classification of
> species capabilities)... and that's the problem with class - "so you go
> to re-implement them as mixins, but now you have to refactor all the
> animals that already rely on those features"
>
> "I also don’t see why refactoring is such a bad thing: as your knowledge
> of the problem domain increases, the structure of your program evolves."
>
> Small refactors are not a bad thing, but class hierarchies create tight
> coupling between child and parent classes (yes, even ES6 class, especially
> with super). In these situations, the dependencies are not always obvious,
> or direct, and they tend to ripple out far and wide, and are not easily
> aided by technology -- it's not a matter of replacing some variable names
> across your project -- it's a matter of reengineering these to deal with
> systemic changes in behavior.
>
> Mixins and other compositional reuse patterns don't create any tight
> coupling between child and parents, and much more easily provide for
> selective inheritance (I only want the banana, not the gorilla, banana, and
> entire jungle).
>
> - Eric
>
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130630/ae45f27c/attachment-0001.html>


More information about the es-discuss mailing list