AW: Best Practices using globals vs. custprops?

Tiemo Hollmann TB toolbook at kestner.de
Fri Jun 22 07:42:54 EDT 2007


Hi Sarah,
yes, whereever it is possible I try it with parametrized function calls, but
I meant overall needed status informations, where there is no need for
persistency. I think there it is more a matter of "style" not to use
globals. Perhaps I'll switch in these cases to custom properties of
mainstack, because they are often not related to any object.

BTW does anybody know if there is a performance difference if you declare
local variables or not? (beside the "style" question)

Tiemo

-----Ursprüngliche Nachricht-----
Von: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] Im Auftrag von Sarah
Reichelt
Gesendet: Freitag, 22. Juni 2007 13:17
An: How to use Revolution
Betreff: Re: Best Practices using globals vs. custprops?

> 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.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list