Re:Refactoring Legacy JavaScript Code to Use Classes
by tchaffee on Tuesday March 07, 2017 @10:52PM
(#13817744)
Thanks for the article, it's a long read that requires some thinking so I'll get to it tomorrow. In the meantime I'll put a Kyle Simpson chapter out there as a rebuttal to "there is not a single disadvantage introduced with the class keyword". He makes a good case that there is more than one disadvantage to the class keyword. https://github.com/getify/You-Dont-Know-JS/blob/master/this%...
Furthermore, Javascript classes make writing mixins AKA composition a breeze, compared to before:
http://justinfagnani.com/2015/12/21/real-mixins-with-javascr...
This link is an excellent rebuttal to Eric Elliot article and how he achieve composition through copying by the way.
So even if you like composition over inheritance, Javascript classes still allow you to write safer and clearer and cleaner code. Now you can do away with ugly factories and property copying.
> Object.assign is far less fragile than inheritance
You realize the using Object.assign means copying properties from object to object over and over and increase memory requirements in order to run a script.
So my point still stands, there is not a single disadvantage introduced with the class keyword.