December 96 - According to Script: Vocabulary Advice
According to Script:
One of the beautiful things about AppleScript is that it allows you to do
nearly anything you want in your vocabulary; however, just because it allows
something doesn't mean that you should do it. To help guide you, I'll regularly
include miscellaneous pieces of vocabulary advice in this column. This time
I'll address words to avoid in your vocabulary. Here are a few examples:
- Avoid using object as the name of a class. If you must implement an
abstract object class, use base class.
- Avoid using the word of in your terms. It tends to be confusing, since
it's used between parts of an object specification. It may not always possible
to avoid this, but think carefully before doing it.
- Avoid using end as the first word of a verb name.
Let's look more
closely at the problem with using end
. Keep in mind that users are accustomed
to seeing end
at the end of a block, and AppleScript automatically appends the
, or the name of the handler after the
if the user types end
on a line by itself. For example:
if the moon is blue
end [if] -- AppleScript fills in the "if"
If you use end
as part of a verb name in your vocabulary, such as end animation
users will type the word end
by itself and expect AppleScript to fill it in. Of
course, this won't happen for a dictionary-defined command like end animation
which isn't a true block construct, so it will appear that the AppleScript
compiler is behaving arbitrarily.
end -- AppleScript doesn't fill in "animation"
This confusion already exists in the case of the Database suite event End
Transaction. In dictionaries of applications that support transactions, users
find themselves having to remove the word transaction
in the phrase end
whenever they recompile a script. Don't create this confusion in
your vocabulary -- it's better to use verb names like start animation
. Users will assume that the full verb name is required.
CAL SIMONE (firstname.lastname@example.org)
plans to include this advice in one of his
future According to Script columns in develop. We're putting it on the CD and
develop's Web site so you
won't have to wait for this valuable information.*