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!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
andSetThing
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!