defining and using globals in an application

Richard Gaskin ambassador at fourthworld.com
Thu Jul 7 11:01:28 EDT 2011


Francis Nugent Dixon wrote:

> I think Scott has the right attitude. Use globals
> if you need them, Use custom properties if you don't
> like the power/scope/limitations of globals.

I would respectfully amend that to read:

Use globals if you need them, use custom properties if you need data 
bound persistently to an object, and use accessors for anything else.

Variables are volatile (they go away when the session ends), and that's 
a very useful feature in many cases.  Binding data to objects can cause 
those values to remain with the object if the object is in a stack that 
gets saved.  If you need values to persist between sessions then 
properties may be the best choice, but if you need volatility globals or 
accessors that use globals can be a better fit.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv




More information about the use-livecode mailing list