Re: On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
Re: On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
- Subject: Re: On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
- From: Michael Kelly <email@hidden>
- Date: Thu, 09 May 2002 12:48:16 -0700
On 5/9/02 12:00 PM, has <email@hidden> wrote:
>
> I also tend to use the same single-character
>
> variable names over and over again for the same types of values,
>
> ie: c == character, i == integer, etc.
>
>
This is telling me what a variable is, not what it does. Two different
>
things, and an important distinction that is easily overlooked.
>
<snip>
>
This is not saying "NEVER use single letter variable names", merely to use
>
names that tell you something useful about the code; things that you won't
>
get otherwise without sitting down and grokking the lot.
I have to jump in here. Aren't the variables c and i somewhat special cases?
For instance, if you're reading a for block, you can always be fairly sure
that i (or $i, depending on what language you're in) is the iterator
variable. c is used much the same way. Using a standardized,
single-character variable name makes the the code MORE readable, if
anything.
Why? First, the fact that the variable is only one character makes it stand
out. Two, you automatically know what it does just by looking at its name.
Three, it's faster to type "i" than "iterator", or "number", or something
else more descriptive.
Single-character variable names are bad if you can't tell what they do, but
perfectly acceptable if you can (as in the case of i and c), in my opinion.
--
Michael
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.