About object-oriented design and the “class” & “extends” keywords in TypeScript / ES6
A few weeks ago I found an interesting article titled In Defense of JavaScript Classes. The article exposed some concerns about the class
keyword in ES6 / TypeScript:
These days it feels like everyone is attacking classes in JavaScript. Developers I respect say ES6 classes are a virus. We’ve compiled long lists on the reasons that ES6 classes are not awesome. Apparently, if we’re still brave enough to try them, we need advice on how to use classes and still sleep at night.
The problems that I see with the class
and extends
keywords in ES6 / TypeScript are not something new. I believe that these problems are cause by bad object-oriented (OO) design and I’m sure that the source of most of the criticism is coming from programmers with a strong interest in functional programming and I understand their fears. They are afraid of some of the OOP “monsters”:
- Inheritance
- Internal classes...