The scope of an item's visibility should dictate how descriptive that name needs to be.
If you literally have a tiny loop, i, j, and k are fine and typical index counters. Sometimes a more descriptive name can help illuminate intent, but if the for loop is set up like the following, then a more descriptive name doesn't really matter.
for (int i = 0; i < totalCount; ++i)
{
Thing& myThing = things[i];
// do stuff with myThing, never refer to i again
}
That said, abbreviations should never be used unless they're used consistently. I personally think ndx
is a terrible identifier because it's hard to type; I can type English perfectly well and my programming speed is not limited by my typing speed. If you want to say index
say index
.
I believe that it was in The Pragmatic Programmer that they said you shouldn't use abbreviations because then people will never know what abbreviation to use. I know I want a thing called index
so I type index
but I get a compiler error. Now what?
As I try to think about it, about the only abbreviation that I use that isn't game specific is 'num' to stand in for 'numberOf'. Other than that I use 'npc' to mean player, etc., etc., and sometimes I use abbreviations in small blocks, e.g. a 10-line function operating on a Camera may just call it 'cam', but the scope is small so it's easy to see what's going on and the possibility for confusion is limited.
So- small scope -> do whatever you like (as long as there's some consistency). Large scope -> make your names unambiguous, meaningful, and easy to type. (By "easy to type" I mean "easy to remember how to spell" as well as "don't go overboard".)