Re: Removing characters from a string
Re: Removing characters from a string
- Subject: Re: Removing characters from a string
- From: has <email@hidden>
- Date: Tue, 5 Nov 2002 16:56:59 +0000
Christian Vick wrote:
>
> I don't think we differ on the issue of using TIDs, Paul. I agree that, if a
>
> script uses TIDs, it should leave them as it finds them.
>
>
What means "as it finds them"? Every script has it's own TIDs,
Correct. Each process maintains its own state, so changes in the state of
one process won't affect any others.
>
so if you know what your script is doing it shouldn't be
>
a problem!??
The keyword is "if". Knowing _for_certain_ "what your script is doing" is
often not as straightforward as it sounds:
- If you're writing a small, quick-n-dirty, disposable script, it doesn't
make an ounce of difference how you code it as long as it performs the task
at hand. Your only requirement is to get the immediate job done in the
shortest possible time. So hack out the code as quick as you can, run it,
then toss it away as soon as it's done.
- If you're writing a routine that will be used beyond the here-and-now, it
makes a lot of sense to take care of all global (TIDs), 'sort-of-global'
(considering/ignoring), and external dependencies (system language, date &
time format, etc.) that affect it. That means including code that makes
them both portable and robust [1].
The second approach _precludes_ the possibility that it might go wrong in
the future due to changes in those dependencies, e.g. if run on a different
machine, incorporated into a larger script... or any number of uses that
you may not have thought of. The aim is to write code that _can't_ go
wrong, rather than code you _hope_ won't go wrong. For small, disposable
projects it may be overkill. Anywhere else, it's common sense.
If unsure which sort your script will be, defer to the latter approach. If
you write a disposable script that you then decide to keep, rework it into
the latter form before keeping it. Truism it may be, but it's always better
to be safe than sorry.
Try doing a Google search on "Defensive Programming". You should be able to
find plenty good further reading. [2]
HTH
has
[1] The exception is, of course, when the routine in question has to be
performance-optimised to the absolute hilt. (But this is a whole 'nother
subject and not directly relevant to the thread.)
[2] See also "Global Variables Considered Harmful".
--
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.