[erlang-questions] Which choice is better? Function or Case

Sun Mar 10 09:27:36 CET 2013

I once had to maintain some code written by a highly skilled
programmer in a language not entirely unlike Erlang.  All the
variable names were one letter or one letter and one digit.

It had me screaming in frustration.  It took me about a day a
page to reconstruct meaningful names for the variables.

I'm trying to think of anything nastier for a programmer to
do to another programmer than to know something the second
programmer needs to know and deliberately choose to conceal
it by using ultra-short variable names.  If I have any luck
I'll let you know.

Seriously, the job of a programmer is to *COMMUNICATE* with
other programmers.  I wish I could offer a simple rule for
how long to make variable names.  My colleague who refuses
to use "i" for a loop index in C++, preferring
innerLoopIndex, clearly errs on one side.  Someone who uses
T for timestamp, tree, and table in the same module clearly
errs on the other.

One rule of thumb I can offer you is this:
there's an interplay between *type* and *purpose*,
in that a variable with a complicated type is likely
to have few plausible purposes in a given scope.
If it's obvious to a reader what the type of a variable
is, you can get away with shorter variables.
For something with a frequently used type, you had
better be clear about purpose.

More information about the erlang-questions mailing list