Best Practices using globals vs. custprops?

Sarah Reichelt sarah.reichelt at
Fri Jun 22 07:17:02 EDT 2007

> on various sites - and again in this best practice thread - it is
> recommended not to use globals, or at least so less as possible, because
> they can be changed from everywhere and that's hard to debug and no nice
> style. I really don't see any difference between using globals or properties
> yet. Properties can be changed also "from everywhere" and even if you write
> a central handler to change your properties, this handler can be called from
> everywhere. What is the best practice for statuses, flags and all these
> global informations, you need at different times and in different handlers?
> And if there is a "clean pratice", what is the difference to using globals?

Firstly, you can often reduce the number of globals needed by sending
parameters to handers & functions instead. This makes for much easier
debugging and maintenance.

Secondly, custom properties are persistent - they are saved with the
stack, while globals are not - they are lost when the stack is closed.
Which you use depends on whether you want to be able to store the data
in the stack or not.


More information about the Use-livecode mailing list