Skip to main content
6 events
when toggle format what by license comment
May 2, 2011 at 17:09 comment added Berin Loritsch @João Portela, I agree that i, and j are commonly used for nested loops (essentially following the alphabet so a third nested loop would use k). Assuming there is no confusion, there's nothing wrong with following convention. I'm just not a fan of that convention because in some fonts there isn't enough distinction between i and j. That's more a problem for proportional fonts which are not typically used for programming, but it's still a potential source of confusion. Having had to use one such font to edit a file, the only difference between i and j was the length of the tail.
May 2, 2011 at 17:01 comment added João Portela I agree that you should always ask those questions. But, in the example you provide you say: "At that point, single letter iterators don't make a lot of sense, because it's so easy to get lost in the scope." and I was trying to show a different (and also valid?) point of view for that same example.
Apr 29, 2011 at 13:09 comment added Berin Loritsch That's why I provided the three questions to ask yourself. It helps work through if the variable name will help/hurt/or is inconsequential.
Apr 27, 2011 at 18:24 comment added João Portela on the subject of the loops within loops, using conventional variable names would not necessarily be a problem and may even be an advantage: if you see a i you know its the iterator of the outer loop, if you see a j you know its the iterator of first nested loop and so on... That being put, it still is a case by case decision.
Apr 27, 2011 at 12:55 history made wiki Post Made Community Wiki
Apr 27, 2011 at 12:23 history answered Berin Loritsch CC BY-SA 3.0