Closed ar0r closed 2 years ago
Could this be phrased in a way that doesn't allude to "later in the degree"? This style guide will be used in other classes and, in particular, Networks does have a strict prohibition on global variables (even though students know about synchronization at that point in the CS degree). Maybe we should say something like "Unless otherwise instructed by your instructor..."
How about: "Mutable global or shared variables can introduce bugs that are hard to detect and require careful design to ensure correctness. Unless otherwise instructed by..."
That sounds good to me. To be clear, the first paragraph of that section would now be:
Python:
Mutable global or shared variables can introduce bugs that are hard to detect and require careful design to ensure correctness. Unless a class you are taking specifically allows you to use global variables, the use of global variables is forbidden, except for defining constants that are set once and never changed throughout the runtime of the program.
C:
Mutable global or shared variables can introduce bugs that are hard to detect and require careful design to ensure correctness. Unless a class you are taking specifically allows you to use global variables, the use of global variables is forbidden, except for defining compile-time constants.
And the rest of the paragraphs would remain unchanged. Is that correct?
Correct. Thanks.
I've pushed this updated to the tutorials
branch.
Alex Kale and Aaron Elmore expressed concern about the blanket prohibition against global variables in the Python Style Guide. After some discussion, we propose this text as a replacement for the current discussion: "Until later in your degree when you learn about synchronization, the use of global variables is forbidden, except for defining constants that are set once and never changed throughout the runtime of the program. There are no other exceptions."