DEV Community

Discussion on: Getters and Setters

Collapse
 
kspeakman profile image
Kasey Speakman

This was (is?) a pretty common way to do things in Javascript. However, it is encoding two different behaviors in one method name. The users of this code still have to remember the two distinct usages and their different outcomes. It being behind one name (and a noun for a method) makes it less intuitive / require some investigation to make sure I'm calling it right. (Especially after I come back to it months later and forgot.) GetThing and SetThing are pretty boring, but usage is obvious. (Although I am not a fan of getters and setters in general.)

I could not agree more about the naming. And nice first post here!