Re: Finder Tell Blocks
Re: Finder Tell Blocks
- Subject: Re: Finder Tell Blocks
- From: has <email@hidden>
- Date: Wed, 6 Mar 2002 16:15:20 +0000
Sander Tekelenburg wrote:
>
> Yeah, I'd second that. While you may be answering a question from one,
>
> you're preaching to an audience of many.:)
>
>
And what's better for one's ego than preaching? ;)
Yeah, well MY ego's bigger than yours, so nar-nee-nar-n... OOPS!!!!
<BLUSH><cough> Ahhhh, moving swiftly on now...
>
Btw, writing easily understandable code alone is not enough (and may not
>
always be necessary even). I find that at least equally essential is to add
>
useful comments to your own code. If at some point you don't understand you
>
code anymore, your comments will help you out.
OK, quick question for the class here. Identify TWO problems in the
following line of code which is taken from a correctly functioning script,
and suggest an improved version:
set x to x + y -- add the account interest to the account balance
Smart cats will of course immediately note that the variable names are
horribly uninformative and promptly address this:
set accountBalance to accountBalance + accountInterest -- add the
account interest to the account balance
Which in turn makes the second problem more apparent: that the comment
doesn't actually tell you anything you can't immediately figure out from
reading the code. It's nothing but noise.
--
>
I tend to add comments to just about everything that is not completely
>
obvious to me.
Yeah, that's the trick: comment the stuff that *isn't* obvious, not the
stuff that is. Even then, you should still ask yourself:
1. could the non-obvious code be made easier to comprehend first?
2. if any obvious stuff only seems that way because your memory of its
design and workings is fresh at the time? [Because it won't be six months
later...]
Ideally, let the code speak for itself as much as possible. Use comments to
*summarise* - i.e. to describe its overall purpose; indicate where and why
workarounds and bugfixes have been used; make difficult concepts and
principles easy to grasp; suggest how future additions or improvements
might be made; etc.
Naturally, it's much easier to write comments about easy stuff than it is
to write ones about hard stuff. The knack is not to waste your time doing
the former thinking it's the latter - you'll keep yourself busy whichever
you do, but only one of them is productive.
--
>
(Hm... Would be cool to be able to toggle comments on/off in an editor. Does
>
any existing AS editor do that?)
IIRC, I once suggested that an editor which allowed outline/collapsable
block views would be jolly nice; someone else kindly pointed out that this
had already been done (not for AppleScript, mind), though I can't remember
its name.
Of course, everybody knows that Real Programmers only write code in hex
editors. And some would hold that even hex editors are a cop out, and that
flipping switches on the front panel is the ONLY way to go. So I reckon us
AppleScript users with our pretty-printing, hand-holding, quiche-eating
editors must be pretty far down on the scale. But hey, at least we don't
wear thick woollen cardigans and the sort of beards you could mop up a pint
with. ;)
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.