lessons from Java, OOP
Dar Scott
dsc at swcp.com
Wed Dec 1 15:55:13 EST 2004
On Nov 29, 2004, at 12:35 PM, Ivers, Doug E wrote:
> Perhaps many of the best scriptors among us implement OOP concepts
> (consciously or not). For example, custom properties might be a good
> way to encapsulate data in a field (or other control). The key here
> would be to write "get" and "set" scripts in the field script and
> never touch the data except by sending messages to these handlers. If
> you do this, please send me tips/advice.
I use custom properties in custom controls and in certain cards and
stacks. I write setProp handlers for these in most cases and getProp
handlers in many cases.
Unfortunately, it is not possible to write such handlers for built-in
properties, so I have to use names based on my own abstractions. Also,
I can't define a custom property named 'text' and use that as the
default property as in fields and images.
For a custom control, the custom properties of the enclosing group
completely define the state of the control in my style. All
interaction is through these. I do not fiddle with the enclosed
objects. (When I'm obeying my rules, which is usually the case.)
I also do this for stacks and sometimes cards. For example, a stack
representing the printed page of an invoice might be specified by a
collection of custom properties. In some cases, most properties are
design time (say margins) and only a few are runtime.
Often, actions are not appropriately state related and using custom
controls may seem silly. In these cases I define handlers that are
called. However, I find that state via custom controls tends to model
how I think of the object in most cases and for most features.
Sometimes I share scripts among custom controls by using a stack
library or an invisible group with a cute image on card 1 (which I call
a badge) or both.
There are other issues with custom controls and I'm still experimenting.
I'm still learning and would be glad to hear of any insights that your
Java experience provides.
Dar
****************************************
Dar Scott Consulting
http://www.swcp.com/dsc/
Programming Services
****************************************
More information about the use-livecode
mailing list