Please. Jump off the abbreviation bandwagon.
Have you ever had to read code with variables like this?
int acBalInSav = 1.21
If you have, and were NOT like “Dude, shit man. WTF does that mean?!”, then you’re probably the one who wrote it!
Stop abbreviating variable names in your code. I’m not talking about so-to-speak “generally accepted” abbreviations, such as using i
in your for-loops. I’m talking about worded variables that are compressed into what you see above.
Why stop abbreviating? Because a) it sucks to read and b) your eyes already do it for you! By shortening the variable name, you’re actually doing other readers of your code a disservice. If you don’t believe me, then try reading the following paragraph.
I cdn’uolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg: the phaonmneel pweor of the hmuan mnid. Aoccdrnig to a rseearch taem at Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a wrod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Scuh a cdonition is arppoiatrely cllaed Typoglycemia . “Amzanig huh? Yaeh and you awlyas thguoht slpeling was ipmorantt.
When you read a word, are your eyes processing every letter of it? No. At least not according to my own experience with the paragraph above (and Wikipedia). What’s happening is your brain is already optimized to process only what it needs to get the full meaning of the words. Usually, that is just the first few and last few letters. There is simply no need to abbreviate variables in your source code.
So if you think you should abbreviate your variables because it will be easier to read, you’re ABSOLUTELY mistaken. If you think you should abbreviate because it will be easier on the computer / compiler / interpreter, then you’re PROBABLY mistaken (source?). You are better off spelling out the word you mean rather than shortening it to an indecipherable length of which only the original author will understand. That way, at least if somebody’s brain really needs to process every letter of the word, it can.
Sources