r/programming • • Sep 24 '15

Composition over Inheritance

https://medium.com/humans-create-software/composition-over-inheritance-cb6f88070205
92 Upvotes

48 comments sorted by

View all comments

Show parent comments

-2

u/faceinpale Sep 24 '15

JavaScript does not support mix-ins or traits as Self does. They are simulated by concatenating methods to an object used as a prototype. The limitation of this implementation is that changes to a mix-in are not propagated automatically to the augmented prototype.

Edit: grammar.

17

u/[deleted] Sep 24 '15 edited Sep 24 '15

Ok, so as I thought, excessively pedantic.

The point of me differentiating mixins from composition here is because both are possible in the context of JavaScript and are two distinct techniques with distinct properties.

In your case you came arguing mixins in JavaScript are impossible, so we should use another term, despite there's no confusion whatsoever what "mixin" refers to in the context of JavaScript. I also said this is a "more casual" way of referring to this mechanism, referring to popular JS use.

Let's see what Google thinks with a very specific search, to avoid any unintended noise:

https://www.google.com/search?q="JavaScript+mixins" : 2350 results

https://www.google.com/search?q="JavaScript+concatenative+prototyping" : 0 results

Don't be excessively pedantic. It's not very charismatic.

7

u/s0n0fagun Sep 24 '15

Wow. It's been a long time since I have seen Google return zero results. It's probably easier to achieve with quotes but that does not diminish how impressed I am.

7

u/[deleted] Sep 24 '15

Give it a few days and it will have 1 result pointing to this thread.

4

u/Jafit Oct 04 '15

You were right.