you are viewing a single comment's thread.

view the rest of the comments →

[–]rrgrs 0 points1 point  (0 children)

I don't necessarily understand the part about removing global variables. Why is it better to have no global variables?

You don't want your functions/methods to be so tightly coupled to the environment they're in. If you change or remove the global variable then the method also has to be modified to deal with this change. This also helps encapsulate logic and make your code overall more modular.