3 ms·
You may want prototype based inheritance like in Javascript/ES6: http://en.wikipedia.org/wiki/Prototype-based_programming http://en.wikipedia.org/wiki/Prototyp
by frik 11y ago
You may want prototype based inheritance like in Javascript/ES6:
http://en.wikipedia.org/wiki/Prototype-based_programming http://en.wikipedia.org/wiki/Prototype-based_programming
- wtetzner 11y agoPrototype-based inheritance seems to be the opposite of what he's arguing for. He's saying it's useful to have data-type hierarchies, but not implementation inheritance.
- frik 11y agoI don't think so. "Prototype-based programming is a style of object-oriented programming in which behavior reuse (known as inheritance) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as prototypal, prototype-oriented, classless, or instance-based programming." In class based programming you have the fragile base-class problem, as the OP mentioned. Prototype based programming is more powerful and you could emulate class based programming in it (as is done in ES6 with the new "class" syntactic sugar).
- wtetzner 11y agoI don't see how prototype-based programming solves the fragile base-class problem. Instead you just have the fragile "base-object" problem.
- kyllo 11y agoThe nice thing about JavaScript is that you have first-class functions that are closures, so you don't have to do OOP at all if you don't want to. And your objects don't have to define methods because you can just define functions outside of methods. And although JavaScript's prototypes don't solve the fragile base class problem, they do offer a handy solution to the expression problem: http://www.jayway.com/2013/06/21/15201/ http://www.jayway.com/2013/06/21/15201/