I read this blog post recently: The Two Pillars of JavaScript Part 1: How to Escape the 7th Circle of Hell, which is essentially a criticism of object oriented programming, and advocacy for funtional programming instead.
Some key points made:
Constructors violate the open/closed principle because they couple all callers to the details of how your object gets instantiated. ... JavaScript doesn’t need constructor functions because any function can return a new object. With dynamic object extension, object literals and
Object.create()
, we have everything we need — with none of the mess. Andthis
behaves just like it does in any other function. Hurray!Classical Inheritance generally lets you inherit only from a single ancestor, forcing you into awkward taxonomies. I say awkward because without fail, every OO design taxonomy I have ever seen in a large application was eventually wrong.
The coupling between a child class and its parent is the tightest form of coupling in OO design. That’s the opposite of reusable, modular code.
Making small changes to a class creates rippling side-effects that break things that should be completely unrelated.
Ok, sure. Without discussing the merits of these arguments (I think the article could do with some code examples) - how is this functional/prototype hacking paradigm used in practise?
ie. Particularly in regards to a framework like Angular or React - where the foundation of components are ES6 classes that extend a framework parent class.