BeginnerMental Models
Lab: reason about a program
Apply the mental models to concrete situations — state, control flow, errors, and agents.
Lab · optionalFundamentalsBeginner10 min
Recommended first
By the end of this lesson you will be able to:
- Apply the program triad (instructions, data, state) to real cases
- Trace an error to its cause, not just its symptom
- Decide when to verify an agent's output
Optional scenario lab. No new ideas — just practice applying the mental models to real situations. Read each scenario, decide, then check your reasoning.
This is where the mental models earn their keep: not as definitions to recite, but as a lens you reach for when looking at real code. Work through these.
Scenarios: thinking about programs
- 1.A shopping cart starts empty, gains items, then is emptied at checkout. In program terms, the cart's current contents are:
- 2.Your program crashes with "cannot read property 'name' of undefined" at line 40. Where is the real bug most likely to be?
- 3.An AI agent wrote a function that looks correct and calls a library method. You should still read the diff and run it before committing.
- 4.Which of these are core ingredients of almost every program?
If those felt natural, the mental models are doing their job. Carry them into every piece of code you read next.
Finished reading? Mark it complete to track your progress.