Re: Finder Tell Blocks
Re: Finder Tell Blocks
- Subject: Re: Finder Tell Blocks
- From: has <email@hidden>
- Date: Tue, 5 Mar 2002 19:18:13 +0000
Sander Tekelenburg wrote:
>
>> writing long, beautiful but complicated sentences. There's nothing wrong
>
>> with beautiful, complicated language (quite the contrary - this world
>
>> lacks it too much), but we shouldn't throw it too easily at new users.
>
>>
>
> I don't think Marc was a new user, he wasn't aware of something and now he
>
> is.
>
>
I don't think it matters how experienced the original poster is[*].
>
Especially when the question is about something relatively basic, I think
>
it's good to write the explanation in a form that is likely to be
>
comprehensible to completely new users. In part because it is hard to judge
>
the level of experience of the original poster, but also because this is a
>
public mailing list, so the answer is likely to not only be of interest to
>
the original poster, but to others as well.
Yeah, I'd second that. While you may be answering a question from one,
you're preaching to an audience of many.:)
--
FWIW, Sander, I do agree that shoving everything into a single line was
unnecessary obfuscation, and simply obscured the code's meaning. It was
difficult enough for me to read that I'd be unwilling to use it even in my
own scripts, never mind in code that anyone else had to grok. Although I
thought your own example:
tell app "Finder"
set theProcesses to name of every process
end tell
if theProcesses contains "MACS"
display dialog true
end if
would actually have been better written as:
tell application "Finder" to get name of every process
if result contains "MACS" then display dialog true
which is concise without being cryptic, and even easier to comprehend.
--
Actually, I think being able to write code that *other* folk can read and
understand with minimal effort is one of the measures of good coding
practice. And if that issue doesn't worry you, consider another question:
will you still be able to grok your own projects 18 months later when
you've long forgotten all details of how they work? Sure it might take a
bit more effort now, but you'll be glad you did later.
Any Fule can write Bad Code, but True Obfuscation takes Practice. ;)
I guess the rule of thumb on how many lines to use should be: "However many
it takes to make the code's function and purpose easy to understand."
Or... If Perl is "executable line noise" and Python "executable
pseudocode", a well-written AppleScript should pretty much be "executable
plain English". :)
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.