re: Are global variables bad? VIEW POST

re: Global is difficult to define. The issue with globals is not that they are global, but that they have a shared mutable state. We should be switchin...

I want to agree, but I've seen the result of this as well, such "single modifier" principles. You end up with a bunch of code that hides variables only to expose a set_x( value ) { x = value; } function -- missing the fact that it makes x a shared mutable variable.

Though I'd say the notion of ownership and control is important, and should be on a list of essential knowledge for programmers. Just like lifetime and visiblity, it plays a major role in where variables are defined.

code of conduct - report abuse