global variables

  • Thread starter Thread starter Reiner Harmgardt
  • Start date Start date
R

Reiner Harmgardt

Hi NG

How about the usage of global variables.

Is it a good advice to use global variables or not?

From my personal feeling and opinion i am not a friend of global variables
because with the slightest error in the application there seems to be a
change
in the variable-environment and the application becames instable
So one has to start again.

What about if i start the application again.
Are there still any variables set in memory from the application that has
been stopped.

Are there any suggestions for the usage of variables in total?

Thanks for helping.

Regards

Reiner
 
You have to be very careful using global variables, but there are times when
their use may be appropriate.

There shouldn't be any risk of values still being set if you restart the
application though.
 
Hi Reiner,

Global variables are not a good idea.

Your cause for uncertainty is also cause not to use them If you see no
other way to get done what you're doing but are getting lost during some of
your troubleshooting, I'd stop the running code and start it over to clear
the variables.

HTH
 
Hi NG

How about the usage of global variables.

Is it a good advice to use global variables or not?

As a general rule, you should avoid them. This is especially so for things
like passing values from one sub routine to another, or passing values from
one form to another. For these types of things, global are a no no.

however, they do have their place and use..and when used right...it is the
right thing to do.

so, things like user name, the cusotmers (client) name that purchased the
software, a sales tax rate etc does make sense as a global.

So, they are not for passing values around..but some values in an
application are global in context..and thus globals often makes sense.

Globals do have their palce.
From my personal feeling and opinion i am not a friend of global variables
because with the slightest error in the application there seems to be a
change
in the variable-environment and the application becames instable
So one has to start again.

If you trap all errors, then global are not re-set. In addition, since any
developer worth their salt distributes a mde, then again any un-handled
error WILL NOT re-set globals. So, this reason alone is a great reason to
always give users a mde, as globals don't get re-set when a error occurs (in
fact, no vars get re-set, and thus code is much more reliable)..


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn
 
Back
Top