14 ms·
Global Variables Considered
- ggchappell 16y agoThere is a side to this particular issue that the writer does not touch on: the pedagogical side. When I read this article, I find myself wanting to know something: was the student told not to use global variables? If so, then the answer to why the grade was reduced, is easy: the student did not follow instructions. Not long ago, I spent a number of years teaching a 4th-semester university programming class. I required my students to follow a relatively detailed (for a class, anyway) set of coding standards. These standards were not necessarily the best they could have been; however, I made no apology for them, because I was trying to help my students learn to build software within externally imposed constraints. After all, anyone who works on a sizable software project -- other than the person running the project -- will almost certainly have to adhere to standards they did not write. There is a good chance that some of these will be standards they are not fond of. That's just the way large projects are. And giving students practice in dealing with this, is, I think, a good goal for a software development curriculum to have. So, is it reasonable to downgrade a student's work severely for including a global variable? That's debatable. But it is definitely reasonable to downgrade for blatant failure to follow instructions. Furthermore, "use no global variables" is, if not the best rule in the world, certainly not a terribly unreasonable one.