Best Practices using globals vs. custprops?

Dave Cragg dave.cragg at lacscentre.co.uk
Fri Jun 22 07:14:04 EDT 2007


On 22 Jun 2007, at 09:50, Tiemo Hollmann TB wrote:

>  I really don't see any difference between using globals or properties
> yet.

Scott pointed out some of the problems of using globals. One  
particular problem in Rev is that we can easily share stacks with  
each other. If you use someone else's stack (as a plugin, a library,  
or as part of your application), and if there is a global in that  
peron's stack that has the same name as one in your own stack,  
unexpected things are likely to happen. That is why it's usually  
advisable to use some kind of naming strategy for your globals. For  
example, start all gloabls with "g" plus your applications name.

gMyAppUserName, gMyAppUserID, etc.

But that's only reducing the risk of name conflicts; it doesn't  
remove it.

Custom properties don't have this problem as thy are tied to objects  
(stacks, cards, etc.) therefore it's OK to have custom properties  
with the same name. (the userID of stack "myApp" versus the userID of  
stack "herApp").

Cheers
Dave



More information about the use-livecode mailing list