Stylebook: Single letter variables - crccheck/crccheck.github.io GitHub Wiki

Avoid using single letter variables.

The rare times it's ok to use single letter variables:

  • Math because there's historical context for what each letter means (e.g.: x/y/z coordinates, i/j matrix indices)
  • i (and sometimes j) for iterators, but idx if it spans more than one line. I can't remember the last time I had to use j now that the functional style of coding is more popular
  • x for instance of an iterable (each)
  • a and b for when things come in pairs (sort, reduce)
  • n is like i but when something is a total/count (not used often these days)

Even when I follow these guidelines, I typically go back and change variables to more detailed anyways.