Why people dislike global variables so much while I find them so convenient?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Jan 25 16:31:21 UTC 2022

On Tue, Jan 25, 2022 at 07:47:12AM -0800, Ali Çehreli via Digitalmars-d wrote:
> Otherwise, as everybody else told, global variables can be very
> dangerous:
> https://www.safetyresearch.net/toyota-unintended-acceleration-and-the-big-bowl-of-spaghetti-code/
> That report mentions "thousands of global variables", all of which I
> bet started as "what can go wrong?"

Further down the article it states "Toyota had more than 10,000 global
variables."  That's... wow.  They must have inherited that code from the
80's or somewhere thereabouts, when this was the accepted way of coding.
By today's standards, I should be surprised there aren't *more*
accidents than there were(!).

And also, the other points in the article about failsafes and single
points of failure, all jive with what Walter has been telling us about
airplane design. :-D


If you think you are too small to make a difference, try sleeping in a closed room with a mosquito. -- Jan van Steenbergen

More information about the Digitalmars-d mailing list