working method?

Sarah Reichelt sarah.reichelt at gmail.com
Wed Oct 26 22:49:13 EDT 2005


On 10/27/05, Charles Hartman <charles.hartman at conncoll.edu> wrote:
> I know this is going to sound like a *really* dumb question, if only
> because it's so vague. But I'm wondering how people adjust their
> workflow to the way Transcript's code is dispersed among many
> separate scripts.
>
> I keep getting lost. I keep forgetting where my code is that does
> such-and-such. (Which script was that in?) So I keep losing track of
> what I was about to do next, and my concentration falls apart. It's
> making Rev *much* slower for me to program in than supposedly more
> complicated languages like Python and C++.
>
> Anybody think this makes any sense? Any hints how to think about it
> differently?
>

Hi Charles,

This is by no means a dumb question and everyone will probably have a
different answer to this, but here's my golden rule: place every
handler as low in the heirarchy as possible.

So if you have a button that does one thing, have the script that does
that thing in the button.
If you have a group of buttons all doing related stuff, put the script
in the group.
If you have multiple objects on the card that need to access the same
handler, use the card script.
For handlers that need to be available to all objects, put them in the
stack script.

Eric Chatonet proposed a neat system a while ago where he annotates
scripts to indicate where the handler they are calling is located. I
forget his exact nomenclature but it was something like this:

on mouseUp
  beep
  setNewColor   -- ∆ C
  set the label of me to "Click"
  doImportantStuff   -- ∆ S
  -- and so on
end mouseUp

Interspersed with commands in the button script, are two handlers that
are identified as being in the card script (∆ C) and the stack script
(∆ S). I don't actually do this myself, but you may find it useful.

Once you have written handlers in a certain place, the next step is to
be able to find them easily. There are a few tricks for this.

Firstly, use long descriptive names for your handlers e.g.
setStackForegroundColor is much easier to understnd than setColor when
you come back to it later.

Secondly, turn on "Show handler list" in the script editor. This gives
you a list of handler names down the side of your script window, which
can be sorted alphabetically or left in the order you wrote them.

My third tip would be to group related handlers in your scripts e.g.
in you have a whole set of color changing routines, put them together
so that if you find one color routine, you've found them all.

I hope you find this useful and I'm looking forward to reading other
people's suggestions.

Cheers,
Sarah


More information about the use-livecode mailing list