Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why are global variables bad?

bad global variables
0
Posted

Why are global variables bad?

0

=================================== us writes (lightly edited): I’ll always fondly remember the outburst of the notorious and seasoned user Lars Gregersen to a recent poster (that most likely started this question) and will give it on to my students: The short answer is: Don’t use global variables. The longer answer is: Don’t use global variables unless you absolutely have to. Now, 1) Using globals is perfectly ok (that’s why they here on first place), just like `for”s and `while”s and other intelligible 2nd generation computer language constructs (that MATLAB is built on). 2) Using globals is a blasphemy from a programmer’s point of view because it shows that she/he didn’t think ahead but was rather sloppy… and just kept adding on those never-ending “important set up” parameters that she/he needed to use by all the axes – or whatever – of a one single project … 3) Using globals is a problem in terms of book-keeping if(f) you end up having zillions of them ho

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.