On Wed, 06 Feb 2008 09:24:49 -0800, Richard Gaskin
<[EMAIL PROTECTED]> wrote:
Devin Asay wrote:
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.
But sometimes that modest effort can pay big dividends down the road.
For example, I have a table object that I use throughout many of the
apps I write. It has a lot of code, and parts are rather tricky,
so if
I replicated it I'd have a lot of replicated code and if I need to
change it I'd have a lot of work applying those changes to each
instance.
So instead I have as little code as possible in the group itself, and
put most of the code in a library. There's only one copy of the code,
and maintaining and enhancing it is a breeze.
Richard I think I see what you''re getting at. Sometimes in an
approximately object-oriented way, I have found that I want different
objects to react differently to the same message: for example in a
simple circuit simulation that I wrote, there are different objects
represented by groups or buttons, each of which represents an
electrical component in the circuit. Having worked out that we had a
live circuit, my app sent a message "apply voltage" to each component
in turn. Within each individual component there was a behaviour (a
method, I suppose) which applied just to that type - a light bulb
would light, a motor would animate, etc. The method was hidden within
the object rather than being further up the hierarchy were it had no
business to be, as it were. This seemed to me a powerful technique,
and indeed one which has far more general application than my simple
example.
However I do see that if there was a lot of complex code needed e.g.
to make the bulb light, and that at the same time there were several
instances of that object, e.g. a lot of light bulbs, then that code
should be in one place (a library) rather than being replicated in
the body of each component. So I don't think the code in the kind of
objects I described could be reduced to nothing (unless the library
contained a lot of impenetrable switch statements to distinguish the
different component cases). I guess this is what you mean by having
"as little code as possible in the group itself". This is not the
same as "no code in the group itself", which seems to me a key point.
Graham
----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution