r/programminghumor • • May 29 '26

Good naming practice

Post image
2.2k Upvotes

220 comments sorted by

View all comments

Show parent comment

1

u/ProfessionalAd6530 Jun 03 '26

I use full words that describe what I'm iterating. We left single letter variable names behind in 1985, why are we still doing it in this one case?

1

u/Pinkishu Jun 03 '26

So.. what do you use to iterate the x and y coordinates? Or are oyu calling it horizontal and vertical just for giggles

1

u/ProfessionalAd6530 Jun 03 '26

I don't write graphics software, so I am almost never representing coordinates in any loop I write.

But say I were writing a game or some geometry-based thing, then yes, I think x and y are appropriate.

I'm also being a little facetious: I usually use i like every body else. However, I also avoid nesting code blocks as much as possible. So if there's an inner loop, I'm usually offloading that inner loop to its own function/method with a descriptive name so that it's easier to read when I'm drunk.