4 ms·
I don't care that he named his variables after women. What I do care about is that he named very temporary variables longer than a single character. 'n' and '
by hereforphone 5y ago
I don't care that he named his variables after women. What I do care about is that he named very temporary variables longer than a single character. 'n' and 'i' suffice and anything else is just pretentious.
- mellavora 5y agoHuh. The standard where I work is foo bar baz In that order
- hereforphone 5y agoThat would be about the time I stand up and leave the interview
- speed_spread 5y agoWhen you realize the interview never ended. Or that there was no interview and they were just having you work for free for the first hour.
- moffkalast 5y agow h y
- cpwright 5y agoI used to use i, j, and k; but at my last job single letter variables were frowned upon so I started using ii, jj, and kk and now much prefer those for simple loops. Searching for "ii" yields the loop much more reliably and quickly than "i" which is often a partial match to other words.
- hangonhn 5y agoOh that’s clever. Thanks for that tip.
- Majromax 5y agoI developed the same habit after working on numerical code in Matlab. `i` can sometimes be sqrt(-1), but `ii` is always a variable. For greatest disambiguation, it's best practice to write `1i` for the complex number and leave `i` unused.
- Cthulhu_ 5y agoOh no that will not do, it has to be descriptive like err, arrayOfUsersIteratorCurrentIndex.
- hereforphone 5y agoarrayOfUsersIteratorCurrentIndex implies you are either joking or are a Windows programer.
- bitwize 5y agoThis is generally regarded as bad programming practice. The standard recommendation is to always use descriptive variable names. Especially since your IDE will help you type them (you are using an IDE, and not trying to bro it out in unadorned vim or Emacs, aren't you?).
- onychomys 5y agoSure, but do you really write loops as (int counter = 0; counter < maxloop; counter++ { printline numberArray[counter] } ? Because that's kind of bonkers.
- jpgvm 5y agoI think "idx" is superior to the other suggested options for this case. It's still short but it describes what the loop variable is for, i.e indexing into the array.
- SloopJon 5y agoNeither counter nor idx strike me as an improvement over i. If you want to be descriptive, name the purpose of the loop variable. If it's an array of foos or an array named foo, then use something like fooIx. Then when you loop over an array of bars, use something like barIx. If you're counting retries, call it retryIx or retryCt (or something that describes what you're retrying, like loginAttemptIx). Depending on the context, i may be fine. However, a single-character name like that is bound to be reused, which is a bad smell.
- throwamon 5y agoYes, it's bonkers to have to write so much repetitive code when you could have a better abstraction such as numberArray.forEach(printline)
- hereforphone 5y agoSounds like you're a Windows and/or Java programmer.