Re:Refactoring Legacy JavaScript Code to Use Classes
by tchaffee on Tuesday March 07, 2017 @10:02PM
(#13817516)
Classes enforce a strict hierarchical relationship which is rarely how the real world works. And you also inherit everything from a parent class whether you need it or not. One alternative to class inheritance possible with javascript is object composition (usually Object.assign()) which does not enforce a hierarchical relationship and you can use only what you want from other objects. More flexible, less brittle. Eric Elliot goes into details with concrete examples in this article. https://medium.com/javascript-scene/master-the-javascript-in...
[ Parent
| on HN ]
There are no comments on this comment yet.