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: Paul Berkowitz <email@hidden>
- Date: Thu, 09 May 2002 12:34:46 -0700
I agree mostly with has in this argument, with the understanding that if
someone like Arthur uses "c" and "I" in the same standard way very time, he
will not only have no trouble remembering and understanding it but may well
spot it more quickly than long descriptive names.
But there are limits to everything. When (usually) near-nebies send in
scripts with immensely long agglomerated portmanteau variable names such as
if theModificationDate of myFirstFoldercalledTodayWithGreenLabel is
greater than YesterdaysRecordedTimeWithoutTheSeconds
I stop reading. I'd much prefer
if modDate of greenFolder > yesterdaysTime
and I'd much prefer this to
if gF's md >yT
but probably everyone's different. My own rule of thumb is to use two
English words (could include 'the') squashed together with perhaps a
syllable or so abbreviated.
--
Paul Berkowitz
On 5/9/02 12:00 PM, "has" <email@hidden> wrote:
>
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
_______________________________________________
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.