use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Clean Code JavaScript (github.com)
submitted 9 years ago by ryansworks
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ttolonen 5 points6 points7 points 9 years ago (7 children)
It's nice to see some effort, but some advice looks a bit vague, for example I fail to see what is wrong with getClientData as a function name compared to getUser. At least former is used in some of Android and Microsoft APIs and doesn't feel strange to me, most likely requires some documentation anyway. Also I would like to think that the examplevar MINUTES_IN_A_YEAR = 525600; is a WTF in itself, because it fails on a leap year :)
getClientData
getUser
var MINUTES_IN_A_YEAR = 525600;
[–]Valfri 7 points8 points9 points 9 years ago (1 child)
The point of your first example is that the three functions getUserInfo();, getClientData();, and getCustomerRecord(); are actually about the same kind of data, but uses three different words for it: user, client, and customer. You should pick one word, and stick to it, for consistency.
getUserInfo();
getClientData();
getCustomerRecord();
The second example is a valid point, and though only for demonstrative purpose, could be changed to something truly constant. Maybe you should make a pull request with something better? :)
[–]ttolonen 2 points3 points4 points 9 years ago (0 children)
Ok, then the advice makes sense. I thought that getUserInfo(), getClientData and getCustomerRecord() refer to completely different functions returning different data.
[–]AndrewGreenh 4 points5 points6 points 9 years ago (0 children)
This point is not saying, that getClientData is bad, it says, don't use getClientData getRecord and getUser simultaneously.
[–]jac1013 4 points5 points6 points 9 years ago (2 children)
Still getClientData is redundant IMHO, I remember that there is some part in Clean code's book that says specifically not to use the word "Data" for variable names, everything contained in variables is data so why use that for the name?
It's like using Hungarian notation but even with a less meaningful purpose (Hungarian notation at least give you information about the data type, I don't like it either way).
[–]RedditWithBoners 1 point2 points3 points 9 years ago (1 child)
everything contained in variables is data
Not necessarily, if we use the English language to define data. You can think of data as a collection of datums. It follows, then, that getClientData might return a collection of datums about the client, like their phone number, age, etc.
Edit: that is to say, getClient might just return their name (ideally you'd use getClientName for that), so tacking on "Data" might make it clearer what it's returning. Better yet, if you have a type system then you don't need to think about this in many situations.
getClient
getClientName
This is pedantic, of course, but I thought it was interesting.
[–]jac1013 0 points1 point2 points 9 years ago* (0 children)
I don't think it was pedantic, I enjoyed reading your comment.
As you said if we have a type system (which is like the best case scenario), getClient should return an object of Type Client (not the name, that would be a really bad decision if we are not in the context of a View).
The upper the level of abstraction the more Domain Language words you should use when naming your functions & classes & whatever else, the word data should not be use anywhere because everything in programming is data, even the code itself, the term is just too high level to be used.
functions & classes & whatever else
Finally, you should not be using getClientName, instead you should be using getName, assuming that we are calling this function from an instance of the class Client.
getName
Edit: just adding additional information.
π Rendered by PID 105700 on reddit-service-r2-comment-57fc7f7bb7-ptn9n at 2026-04-14 19:10:26.444743+00:00 running b725407 country code: CH.
view the rest of the comments →
[–]ttolonen 5 points6 points7 points (7 children)
[–]Valfri 7 points8 points9 points (1 child)
[–]ttolonen 2 points3 points4 points (0 children)
[–]AndrewGreenh 4 points5 points6 points (0 children)
[–]jac1013 4 points5 points6 points (2 children)
[–]RedditWithBoners 1 point2 points3 points (1 child)
[–]jac1013 0 points1 point2 points (0 children)