Re: Finalizing Script
Re: Finalizing Script
- Subject: Re: Finalizing Script
- From: has <email@hidden>
- Date: Thu, 29 Aug 2002 16:23:59 +0100
Greg Back wrote:
>
I have written the following script, and am planning to post it to
>
applemods in the next couple of days. I was wondering if any of you
>
scripting experts had any tips for optimizing or simplifying the code.
>
Thanks in advance for all help.
Here's a few very quick thoughts off the top of my head:
- For readability, I think having another look at your handler names would
help clarify their behaviour - eg: ChangeBase(num, fromBase, toBase)
- For robustness, all parameters should be checked for type and range. As
your script uses TIDs, the current TIDs should be preserved before you
change them, then restored before the handler returns/when an error is
thrown.
- In error reporting, don't use a dialog box to report errors. This is much
too specific: actually _deciding_ what to do when things go wrong should be
the _caller's job_, not yours. Your task is merely to inform them what as
gone wrong. Have your module throw its own custom error. Each error you
throw should have: 1. a message explaining the problem, and 2. a suitable
error number [unique, if necessary] so that the caller can trap and handle
specific errors if they wish.
- User documentation. (I know it's not strictly relevant to your question,
but I think it helps to take the holistic approach with stuff like this.)
- Test your code thoroughly before release. Don't just test it with valid
data (although you should, and preferably with a good range of values); try
it with invalid data too to make sure that bad values are caught and
reported.
Your code could certainly be tightened and improved both for speed and
simplicity, but I can't really help here as I'm a bit short of time at the
moment. Still, the first thing is to make sure it's solid and working
before worrying about optimisation, so even the above should give you a bit
to work on. Anyway, good luck.
has
>
PS. And yes, I still use ScriptToEmail, has.
LOL... you and me both, bud, and nobody else;). Though I notice it doesn't
like it when the code has trailing whitespace removed from the end of
wrapped lines by the email app/list server(?). Guess I'll need to change
how it handles line wraps sometime. (Though it's such hoary old code that
I'll probably have kittens to look at it now...;)
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.