News for hackers. Stuff that matters.
Re:When I use classes, when I don’t, what I do instead and why by seasonalgrit on Sunday November 19, 2017 @03:41PM (#15735819)
If you're going to go with a functional approach (which he introduces in the section "How to avoid 'this'"), instead of creating a brand-new function for each particular piece of data (e.g., setName, setGreeting) -- which will result in a ton of extra code -- just use a simple, generic assoc function.

"Inventing a class with its own interface to hold a piece of information is like inventing a new language to write every short story." -- Rich Hickey

Re:When I use classes, when I don’t, what I do instead and why by deckar01 on Sunday November 19, 2017 @06:24PM (#15736550)
I actually have to maintain a js codebase that uses a generic “addProperty” function at its core to generate getters and setters. It is terrible to debug. Properly encapsulated class methods are much easier to read and debug.

This problem has been solved for a long time. Some data doesn’t need a class, but when it does, don’t roll your own.