LightMySky

Reading a Program Someone Else Wrote

Most code a person meets was written by somebody else. Working out what an unfamiliar program does, and then changing it on purpose, is a different skill from writing one from a blank screen.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Say in one sentence what an unfamiliar short program does, before running it
  • Point at the part that would have to change to alter one named behaviour
  • Make that change without breaking the rest, and say what was checked afterwards

1 · Read

Most code you meet was written by somebody else. Reading it differs from writing it. Your first job with a strange program is to say in one sentence what it does, before you run it.

Try it together

Read this line: if 7 > 5 then 10 else 20. The test 7 > 5 is true, so the program picks the value after then, which is 10. Try another: if 3 = 4 then yes else no. Here 3 equals 4 is false, so the program picks the else answer, which is no. Branches set the kind. Words compare too.

To change one behaviour, point at the part that controls it. In the line if score >= 50 then pass else retry, the test score >= 50 reads as score is 50 or more, and the pass mark lives inside it. Raising the mark to 60 means changing that number and nothing else.

After any change, check the rest still works. Rerun an old case that should stay the same, plus the new case you wanted. If 4 degrees now reads icy while 11 still reads ok, your one change landed cleanly.

Predict from reading, change the one part in charge, and recheck old plus new cases.

2 · Watch

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Where this leads

Jobs that lean on this skill. Follow one to see everything it is built on.

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Reading a Program Someone Else Wrote · Computing, ages 13 to 14 · LightMySky