[futurebasic] Re: [FB] Global vars (was: CFString )

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2008 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sat, 19 Jan 2008 17:42:38 -0700
On Jan 19, 2008, at 4:13 PM, Brian Stevens wrote:
> 1) Global vars cannot be used in a local FN with a "clear local  
> mode" header, so global var usage in FN IterateFolder is DOA.

Just a couple of reminders on global vars folks. I know some of you  
love them but if you write larger programs they tend to cause bugs.  
Also, globals are persistent. Once allocated they stay around until  
the program quits. Local vars are allocated on fn entry and disappear  
on local fn exit. This makes the program more efficient.  The most  
difficult aspect of globals is program maintenance and bugs. A global  
var can be changed anywhere. If I'm looking for a bug with a local  
var my search is limited to just the local fn.  If you must use  
globals, establish a setter function to change the global and then  
always use the setter. This has the advantage of changing the global  
in only one place which makes it much easier to trace. There is more  
to write on this topic but enough for now.

Good evening...


Brian S.