On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
- Subject: On variable naming... [was Re: AsciiNumber & AsciiCharacter Handlers]
- From: has <email@hidden>
- Date: Thu, 9 May 2002 20:00:38 +0100
Arthur J Knapp wrote:
>
> This is much more legible [1]. Not just to novices, but also to experienced
>
> scripters and even the original author.
>
>
If I am the original author of which you speak, I'm afraid I have to
>
disagree, though I'm willing to admit that I may be unique in this regard.
Oh, I think you're definitely unique, Arthur... In a nice way, of course.;)
But you know me, I'll bite anything...
>
This is an overload of close-fitting big words and whitespace-delimited
>
references that takes my eyes a while to "parse". I find it difficult to
>
read code in the same way I would read a novel.
I wonder if there's any psychologists in the audience would be able to
comment on the pros and cons of reading verbose, English-like code versus
terse Perl-ish or C syntax? I think the brain's supposed to be quite good
at pattern recognition stuff - e.g. something like "AppleScript's text item
delimiters" may not be scanned and parsed word-by-word, but identified at a
glance as a single meaningful block item.
In more
>
traditional languages, I have an easier time writing code that I can then
>
later read quickly and immediately comprehend what is happening:
This may be more a matter of personal preference than down to cognitive
function. Again, I'd have to leave it to the experts to comment on.
>
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.
I've seen various criticisms of the "code that fails to tell me anything I
didn't know already" tendency [best exemplified by the "set x to x + y --
this line adds y to x" school of commenting], but I can't recall seeing
anyone actively advocating it. (Not that this stops folks from using it in
their code, readability issues or no: short-term convenience often wins
over long-term security and common sense.)
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.
Cheers,
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.