Lesson 3 of 48
Variables and state
A box with a name, whose contents change while the procedure runs.
State is what makes a program hard. The same code with different state does different things, which is why “it works on my machine” is a sentence that exists. Naming the state and knowing when it changes is most of debugging.
Do this
Build a small project with a score that stays correct after every possible sequence of actions — including the awkward ones somebody would try in order to break it.
The question that unlocks the next lesson
Two lines of code are identical but produce different results on two runs. What must be different?
- AThe language version
- BThe state those lines read from or write to
- CNothing — identical code always behaves identically
- DThe order the file was saved in