AW: where to put handlers?

Devin Asay devin_asay at byu.edu
Wed Feb 6 10:05:16 CST 2008


On Feb 6, 2008, at 2:06 AM, Tiemo Hollmann TB wrote:

> Hi Mark,
> Interesting to read that totally opposite approaches are both  
> favoured.
>
>> A lot of projects that are sent to me are unnecessarily complex
>> because people try to be "smart", putting handlers in weird places.
>
> Btw. I go the same way as Sadhu and feel comfortable with my way,  
> especially
> in maintenance cases, where I don't have to think about where a  
> handler
> could be placed. In smaller projects my "weird place" for almost all
> handlers is the stack script. I do actually have only one single  
> mouseup
> handler in stack script, with cases of targets. So I uncoupled  
> logic from
> design, what has advantages and disadvantages. I don't know, if and  
> how my
> approach would work in bigger projects, but up to now, its good for  
> me.

I have two objections to placing all handlers high in the message  
hierarchy.

1. It destroys the modularity/object-oriented-ish-ness of Revolution  
stacks. If I create a particularly brilliant object (or at least a  
complicated object that is "good enough") I often want to re-use it  
in other projects. If I've separated the scripting from the objects  
it becomes much more difficult.

2. As a project grows in complexity, a stack script that contained  
all handlers in the stack could easily swell to several thousand  
lines. In this case it actually becomes *harder* to maintain, as you  
must scroll or search through a huge script to find the handler  
you're looking for. It even becomes difficult to find a handler in  
the handler list of the script editor as the number of handlers  
multiplies. I once inherited an extremely complex project in which  
the original programmer had used the approach of placing all  
scripting in the stack script. While the handlers were well-written  
and well-documented, and the stack worked pretty well, I had a devil  
of a time figuring out which handlers did what, and to which objects  
they related. After several months I *started* to get the hang of it,  
but I lost a lot of time figuring it out.

I like Jerry Daniels' axiom: Put handlers as high as they need to be  
in the hierarchy, but no higher.

My $.02.

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list