Meaningful Identifier Names: The Case of Single-Letter Variables – Dror Feitelson

So, we hate one letter identifiers, right? Variable names should be meaningful! But… for a loop it might be a bit too much. Dror and his students wanted to study this, focusing on these questions.

  1. How common are one letter identifiers? For C, Java, Perl, PJP and JavaScript, they took the top 200 most popular projects, and plotted the length of variable names:

    And, there are different letters which are used across the languages.

    Does they use impact understanding?

    Dror then did two experiments comparing code snippets with one letter to full names, but he measured no difference, so maybe there is no effect or a small one (although this could have been due to too hard exercises)

  2. What do they convey?For the third part, also really cool, they surveyed the meaning of all single letters, with these results:

So while you might think that it is clear what a letter means, it might not be the case for everyone!

This post was visited 521 times.