Re: engineering a global type a variable...


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.


"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.

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??

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
MVP Tips: