Re: Default or optional arguments to handlers
Re: Default or optional arguments to handlers
- Subject: Re: Default or optional arguments to handlers
- From: has <email@hidden>
- Date: Wed, 24 Apr 2002 00:00:18 +0100
Paul Skinner wrote:
>
I do this like so...
[snipped code]
2c here, but...
KISS. If it seems too clever, it probably is. (This goes double for kludges
and hacks imo.)
I think there's a decent argument for using the single-record-as-parameter
kludge where you're writing a handler [library] that:
1. will be distributed to third parties; and
2. you're pretty certain that you will be expanding a handler's
functionality in future releases; and
3. those expansions can't comfortably/logically be handled by adding
additional handlers [eg foo(), fooPlus()].
I also think it's allowable when you really need to provide optional
parameters and the advantages of these outweights the disadvantages of
using a kludge (e.g. lots of fine-tune options, most of which the user will
want to leave set to built-in defaults for most of the time).
However, I certainly don't think it's a practice that should be encouraged
by default: it adds complexity, which in turn impacts both performance and
code readability/maintainability.
As for putting documentation within the handlers themselves; well, inline
comments for coders I could understand. But big hulking records - I can't
see the value of that. Besides, there's a basic paradox here: to use read
the user documents, you have to know the handler names. Therefore you have
to document them. But if you're documenting them separately, what's the
point of including user documentation within the handlers themselves? It
makes little sense. If you really want built-in documentation, put it all
in a string (simple; also semi-readable by looking at the code itself), and
return the string via a standard call, say man(), which is the same across
all your modules. (Though still overkill, IMO - a plain text file does
everything you need of mod documentation, and more simply.)
Cheers,
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta 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.