Replies: 1 comment
-
I remember this exercise, from when I was teaching it last year! This was absolutely one of the most difficult examples to teach from. I checked in some minor changes so that the code actually worked without errors, but I didn't have a clear plan for actually adjusting it so that it made sense. If I remember right, we ended up picking a small subset of the code, walking through it, and asking some very specific questions about it, and then moving on before anyone could get too confused -- and covering global vs. local variables in other contexts later, where they made more sense. I agree 100% that the sample code as it stands does not do anything useful with global and local variables. It's kind of a programmer's shell game, designed apparently to trick everyone into getting the wrong answer. Any redesign would almost certainly be an improvement! |
Beta Was this translation helpful? Give feedback.
-
Lab 3.04 has sections Problem 1, Problem 2, Problem 3. Students are asked to decide if there is a problem in the code. But we never tell them what the code is supposed to do.
The example itself seems a bit contrived. I can't imagine anyone writing something like that. This is a bad example to have students study. Let's not do that.
For anyone trying to figure out what we are trying to show them:
Beta Was this translation helpful? Give feedback.
All reactions