Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
If you use one letter variables then you deserve to get your throat slit and your head bashed with a rock.
-
RTRMS36906y@Michelle I shit you not, I freelanced on a project, and the shittest most god awful code was that of the CTO, single letter variables, es5 in an es6 code base. For loop in a floor loop ending with a map... WTF...
Its fucking crazy after an hour I still had no idea what it was doing. -
RTRMS36906y@ruro yes, we have transpires to make the code useless to humans reading them.
Its not the year 2000 where we need to manually save every byte of code ourselves by making tiny useless variables.
I look at your code and see:
const m = 'Loren';
That is fucking meaningless, what is the context of m, what does it mean, what's its purpose in life, yeah now I write m, so to make sure the next guy knows what it is I need to add in 2 lines od comments to explain m instead of just goinf
cost mothersName = 'Loren';
Poof, now everyone knows exactly what it is, it's purpose, context and suddenly no need for 2 lines of comments, or any comments.
Back in my compiled code, I don't give 2 donkey fucks what it looks like, it's uglified and minified, space saved, but in the dev code base, you send me a PR with shit like that I will reject it, delete the branch and block your fucking repo access for a week so you can spend that time better learning how to do your damned job properly. -
ruro316y@RTRMS I still disagree. Fields, classes and functions should always have self-explaining names, but local variables *may* not. Because long names can sometimes lower readability.
I provided an example in which I think the full local variable name doesn't contribute to readability.
To which you replied with something completely unrelated about mother name.
Context is important. I bet even you don't use full names for iteration indexes (i,j,k). It is a convention and it is obvious from context.
Sure, there are cases, where fully qualified local variable names are better, but that is not always the case.
And in case you think, I am just one crazy guy, many big respectable open source libraries use one letter variable names, when appropriate. For example, numpy and libstdc++ (gnu).
What I am trying to say is that there is nothing *intrinsically* bad about one letter variable names. If you use your brain and follow conventions, it's totally okay.
Remember to use good coding practices
joke/meme
k = "null"
j = k
i = j