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: Arthur J Knapp <email@hidden>
- Date: Fri, 10 May 2002 13:47:57 -0400
>
Subject: Re: On variable naming... [was Re: AsciiNumber & AsciiCharacter
>
Handlers]
>
From: email@hidden (Michael Sullivan)
>
Date: Thu, 9 May 2002 16:12:05 -0400
>
Arthur's style is actually pretty close to Kernighan and Plauger
Uh, ...
>
... in _the
>
Elements of Programming Style_, which is some folks (including mine)
>
Strunk and White of coding style.
Oh, Strunk and White. Well, that clears that up. ;-)
>
In any case, they specifically argue that single letter variable names
>
are just fine (and maybe better than long descriptive variable names)
>
when they are for standard idioms or used in fairly simple 1-5 line
>
functions that can be understood quickly.
Yes, thank you. Many handlers of mine are in the 2 to 5 line length
catagory, and I just can't see the objections that some people have
to single characters variables in these situations when their intended
meaning/use seems so self-evident, (again, maybe not to the absolute
beginner).
>
To be honest, I think the line where smaller variable names help is
>
actually farther along in Applescript than in a very terse language like
>
C or Perl. There's something about a regular breakup between short and
>
long to make visual parsing easier. So in C (and especially perl!),
>
almost all operators and keywords will be terse, so long variable names
>
help distinguish variables visually.
>
>
In applescript just the opposite is true. Keywords and operators are
>
often long words or phrases, so having short, or single letter variable
>
names, helps visual parsing of a statement by making the word breaks
>
less homogeneous.
This is an interesting and, (I believe), insightful observation.
>
Obviously this breaks down when your function gets complicated enough,
>
or contains enough different variables, that you start having to spend
>
energy keeping track of what is what. At that point it becomes very
>
helpful for the variable names to do this for you.
Right. The key is effiecent use of handlers and objects, of course, for
keeping everything within a smaller and more manageable context, but even
then, complex projects do require highly verbose and descriptive variables.
>
But using a,b,c... for numeric arguments or i,j,k... for loop indices
>
are so normal and standard that, IMO, they remain very readable even
>
within quite complicated functions.
>
>
I also often use this idiom for handlers
>
>
on function(longDescriptiveArgumentName)
>
>
set a to longDescriptiveArgumentName
>
-- go on to do stuff with a
I sometimes do something similiar, but usually it is in the context of a
parameter with more than 1 allowed class:
on function( initialList_orLength_orText )
...
>
In any case, with everything I've seen of Arthur's, I pretty much agree
>
with his decisions on this front, and I've stolen a number of style
>
idioms for line break and tabbing decisions in applescript from him
>
because I find them very readable. I'm hard pressed to name anyone
>
who's applescript code presentation I like better.
[blush]
There's something in my eye, please excuse me... ;-)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www.seanet.com/~jonpugh/>
on error number -128
end try
}
_______________________________________________
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.