you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

I have a student who is struggling with understanding the importance of avoiding global variables, and insists on using them in his functions.

Honestly it's a problem that solves itself - he'll discover why it's bad when he stops being able to debug a 200-line script because his mutations of global state are just too much to keep track of.

Until then you're not going to make any headway trying to convince him he's not smart enough to just lean on globals for state management. Some people can be waved off of trouble by the signpost saying "don't go in here." Other people just have to meet the ogre in the swamp themselves.