DIMAJIX - software consulting (http://www.dimajix.de/)
 

Global Variables


Recommendation 21. Avoid global variables.

You should only use global variables if there really is no other possibility or work-around. In many cases it is better style and more transparent if objects are explicitly created on the stack instead of having them created automatically at startup as static objects.

Furthermore global variables always cause problems in multithreaded applications if no special care (mutexes) is taken to avoid concurrent access by two different threads. Even if you do not plan to use multiple threads, you still should obey this recommendation - maybe you want to reuse your code in the next project that is massively multi-threaded.



Kaya Memisoglu 2005-01-06