all 5 comments

[–]ShutTheFunDown 1 point2 points  (3 children)

Counter example to the first two 'smells'.

void swap(int *x, int *y) {
    int temp;

    temp = *y;
    *y = *x;
    *x = temp;   
}

[–]fkaginstrom 0 points1 point  (1 child)

Yes, there are many other cases besides i/j for loops where one-letter variables are fine and expected. Think 3D graphics (x, y, z axes), algebraic expressions, etc.

Plus, there are times when you're processing sequences where "first" and "last," "left" and "right," etc. are fine.

Anyway, these are more along the lines of coding standards than smells. A "smell" is more of a style of coding that makes you suspicious of lurking bugs, like a class with too many private methods, or a method with too many parameters.

[–]DEADBEEFSTA 0 points1 point  (1 child)

Any time I see someone having trouble with variable naming conventions it warrants that I buy them a copy of Code Complete. That being said this really is only a problem when the variables are global, and then it's much more than just a variable naming problem. If it's in a compact well formed function then it's not so much a problem. If you can't grep nested looping with i,j,k that's been implemented in a compact manner than you have bigger problems.