Hacker News new | ask | show | jobs
by unifyjs 1487 days ago
My initial gut reaction to this was "%$#@ no!", but there are some well reasoned answers here from both camps. The overriding takeaway here is "there is a happy middle ground".

Personally, I have often found that once you try to scale complexity much past the canonical "Student is-a Person" example, it's extremely difficult to avoid violating SOLID principles, and things turn to a big ball of mud pretty quickly.

This is mostly due to inheritance being way overused. Even the initial creators of OOP stated "prefer composition over inheritance" [1], but this seems to get forgotten more often than not. Couple this with Javascript's well known issues with the "this" keyword, and you've got a recipe for disaster.

I avoid the OOP "pillar" of Javascript [2] for these reasons, plus the fact it just isn't required - I never wonder whether the caller has messed with "this", never need to use "bind", etc. etc. "Scoping by function" is a concept I'll blog about sometime soon.

[1] - https://en.wikipedia.org/wiki/Composition_over_inheritance [2] - https://medium.com/javascript-scene/the-two-pillars-of-javas...