Best Practices Question

Andre Garzia andre at andregarzia.com
Thu May 28 12:01:20 EDT 2009


Bill,

welcome to the Revolution. I am by no mean some expert on best
practices and anybody who read my code knows that (at least I fail in
a consistent way, I always mistype heigth the same way).

Talking a little about scope and when I use global, script, temp
variables and custom properties.

I use globals when I need sharing the data all across multiple
scripts, stacks and the like and the data must be forgotten between
runs. So, I use it for wide spread temporary data but these days I use
only one global and that global is an array where I can put anything I
want and still keep the global clutter low.

I use script local variables when I need something shared between the
handlers and functions of a single object (or card or stack or
library). So if I am building a library, that library will not have a
global for sharing data with itself but will indeed use script local
variables.

Temporary variables are used everywhere...

And I use customprops with data that needs remembering or are multiple
line. If I need to store the data I am using, I will use a custom
property or if I am fiddling with some constant or some data that will
be used by my software as opposed from data that is inputed from
keyboard or other data sources, then I will use a custom property.
Common uses for me is storing templates and pieces of messages to be
assembled later and presented to the user. I also store binary chunks
in custom properties when needed. For example, storing curl.exe inside
a custom property and pipeing it out case the windows user does not
have curl installed and I need it.

Cheers
andre



More information about the use-livecode mailing list