Re: engineering a global type a variable...



Joe,

I agree with you. While it isn't "incorrect" it is a maintenance hassle. I try to keep variables as close to in scope as I can. Global variables that are accessed by threads other than the UI are almost always a nightmare to manage.

Tom

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message news:t0a2d4tg5gqfiu81k97m23vdbkcv9qfifo@xxxxxxxxxx
It is called "A maintenance nightmare". Dialogs that depend upon global state rapidly
create situations in which it is nearly impossible to actually maintain the code.

Memory leaks are not an issue here. Unmaintainable code is the issue.

In the presence of windowing and multithreading, global variables tend to cause
malfunctions because the assumptions you made when you wrote the code change in a few
months but you've forgotten about the global variables.
joe

On Tue, 9 Sep 2008 10:30:14 -0700 (PDT), RAB <rabmissouri@xxxxxxxxx> wrote:

Why would using a global variable be incorrect? I don't want to be
contrarian but rather am trying to learn. I have seen this on other
posts but do not understand why? Does it cause a memory leak?.. app
more likely to crash at run-time??

Thanks,
RABMissouri
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

.



Relevant Pages

  • Re: Memory Leak with AnsiString
    ... It worked very well and it didn't cause memory leaks at all. ... treatment of global variables by the runtime code did, ...
    (borland.public.delphi.non-technical)
  • Re: Global Variable vs Hidden Input TextBoxes
    ... that I might lose global variables due to memory leaks and other ... I think you are being overly-paranoid about memory leaks losing global variables though. ... Chance Favors The Prepared Mind ...
    (comp.lang.javascript)
  • Re: Many global vars in an A97 app - good or bad? Why?
    ... especially the past about appropriate scope. ... >Passing data between forms: why do so few people know about the ... >>Global variables are decidely poorly suited to these two purposes, ... This could be a global class module variable, ...
    (comp.databases.ms-access)
  • Re: How to eliminate this global variable, silent?
    ... Excluding it because it doesn't have global scope is perfectly correct. ... The only argument you can present is: the standard doesn't ... define "global variables". ... yadda yadda. ...
    (comp.lang.c)
  • Re: Trouble with variable scoping
    ... You are confusing file scope with global. ... That is possibly the most common misperception about Perl that I've ... fully-qualify any global variables you decide to use. ... a lexical variable $foo exists in the current scope. ...
    (perl.beginners)