628
you are viewing a single comment's thread
view the rest of the comments
[-] kionay@lemmy.world 9 points 1 year ago

I prefer index variable names that are two words. The second word is always 'index' and the first word describes the enumerable objects. carIndex, productIndex, thingIndex

I'm not paid by the character count. Longer and more descriptive is better. Long lines that go past your 1080p monitor are probably not long because of variable names but because you insist on doing many things in one line (quit doin' that). For small functions this isn't necessary, but too often I'm shunted to the middle of a big function with two or three indecies doing acrobatics over one another and while working on it I have to constantly remind myself that this i and j mean particular things.

[-] GhostlyPixel@lemmy.world 4 points 1 year ago* (last edited 1 year ago)

I have had too many times where I have been confused trying to figure out a giant nested loop because the writer used i/j/k or x/y/z. It’s even worse when they confused when a particular bug is because they confused what their single letter variables were and used j somewhere instead of i and no one caught it because it is so easy to brush over. Name your stuff what it is, make your life easier, make others lives easier.

[-] LetThereBeDwight@lemmy.world 3 points 1 year ago

If you need three iterators, it's time for at least one function encapsulating that inner loop.

this post was submitted on 09 Jul 2023
628 points (94.0% liked)

Programmer Humor

32600 readers
530 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS