On Variable Naming in Code


December 15, 2006

night

Much is made of the pain of typing long variable names (or function names or class names), but code is usually read more often than it's typed. And when I'm reading code (even if it's my own), I'm grateful for names that err on the side of descriptiveness.

This means:

The exceptions are common language idioms which any programmer could reasonably be expected to know (ie: cons in Lisp, def in Python, x as an index into array loops). These should be abbreviated as their meaning is more intrinsic and independent of the name.