DEV Community

Discussion on: Stop Using JavaScript Classes!

Collapse
 
assertnotnull profile image
Patrice Gauthier

Classes in Javascript are very basic. The real benefit is DI when using decorators with Typescript. In one of my previous work I saw that if there's no clear structure in place it becomes a mess and over time I feel now that JS development suffers from a common structure, conventions. At scale the benefit of DI becomes useful but then when you reach that stage then you already have a mess that is too big to tackle and not worth it business wise. Developers create low quality code as result and best practices are an ideal in theory. Functions with 600 lines were looked over like it's fine and the company was just 5 years old. We really need to use something like Nest.js.

Collapse
 
jaraujo6 profile image
Johnny Araujo

Nest.js is one of the few exceptions I make when it comes to using classes in Node. Thanks for reading!

Collapse
 
kulaggin profile image
KulaGGin

DI becomes useful immediately with 0 lines of code. The mess will slow you down in minutes, not years. There is no excuse not to use best practices such as TDD and applying design patterns even for personal projects.