2 ms·
Length (as proxy of expressiveness) of variable name should be a function of the scope of the variable. It there are only a few lines between declaration and la
by schlupa 6y ago
Length (as proxy of expressiveness) of variable name should be a function of the scope of the variable.
It there are only a few lines between declaration and last use of a variable a single letter name is often suffcient (i,j,k for loop vars, p, q, r for pointers, l for length, n,m for upper bounds, a,b,c,t, etc. for temporaries.
If the scope is over a longer section, without to much repetition it is appropriate to have a longer name.
If it is a global variable with external linkage, it is very good to have a descriptive name so that it is also clear what it is when looking from outside.