3 ms·
Wow, different strokes. I wouldn't want anything to do with code that used variables like "SkuNdx" over a simple i, j, or k. That said, ideally I prefer using
by Locke 18y ago
Wow, different strokes. I wouldn't want anything to do with code that used variables like "SkuNdx" over a simple i, j, or k.
That said, ideally I prefer using languages with each or foreach or a similar construct. If you want to iterate over a set of objects, you should only have a variable for an object. Who cares about the index?
foreach( sku in skus )
Or
skus.each do { |sku| .... }
If you reserve i, j, k for cases where you actually need an index, I think you'll find that i has even more meaning: i is an index and it's presence means the index is actually important. That's a lot of meaning for a single letter.
With respect to what other programmers might do, I think "defensive" programming is a waste of energy. A bad programmer will screw up your code regardless of what you name a variable. The best you can do is avoid working with such people. If that doesn't work, write unit tests. Seriously, at least then you know that a bad programmer broke your code before you get a call.
- edw519 18y agoThe best you can do is avoid working with such people. If only. I actually laughed out loud when I read that. Exactly what we just talked about over lunch. (How can someone be so smart, personable, and pleasant, and still write code like that.) OTOH, another great argument for starting your own.
- jrockway 18y agoWith respect to what other programmers might do, I think "defensive" programming is a waste of energy. A bad programmer will screw up your code regardless of what you name a variable. The best you can do is avoid working with such people. Exactly. I had a really hard time working with normal programmers... I would explain why I did something that wasn't brute force, they wouldn't get it and their way also worked... so the codebase was one big festering pile of shit. Now I work somewhere where my coworkers are arguable some of the best programmers in the world... and I don't have this problem. Life is too short for bad jobs. As a programmer with a clue, you are a very hot commodity. So go somewhere where you won't want to kill yourself at the end of the day. (Or start your own company, of course. Then you really get to pick who you work with.)