Global Variables Are Evil

Global variables are evil because they can be accessed / modified from any functions. This make every function potentially dangerous.

If you are the only developer for the product, then global variables may be acceptable (you should still keep them to a minimal), but how often is this the case. In real world scenarios, developers come and go. If you don't keep an eye on global variables (document all the global variables that you use), you will quickly forget about them. If you have a new team member, you may forget to train him and let him know about the global variables that you have.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License