uchicago-cs / student-resource-guide

UChicago CS Student Resource Guide
BSD 3-Clause "New" or "Revised" License
12 stars 5 forks source link

Proposed change to the Python Style Guide #7

Closed ar0r closed 2 years ago

ar0r commented 2 years ago

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."

borjasotomayor commented 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..."

ar0r commented 2 years ago

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..."

borjasotomayor commented 2 years ago

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?

ar0r commented 2 years ago

Correct. Thanks.

borjasotomayor commented 2 years ago

I've pushed this updated to the tutorials branch.