S4 ICT: Debugging and Version Control (three error types, binary-search debugging, commits and rollback) Tutor Prep Guide with a 45-minute plan, teaching script and common errors
- 2026-11-15
Students add prints from the first line whenever something breaks, and cannot say how many attempts that costs. This lesson turns debugging into three error types plus binary search, and shows why version control is a safety net.
01 Prerequisites (3-minute check)
If any of these fails, fix it before the lesson starts.
| Skill | Quick check | Pass mark |
|---|---|---|
| Powers of two | Which power of two exceeds 600 | 10, since 1024 does |
| Percentages | 114 passes out of 120 tests: the pass rate | 95 per cent |
| Addition and subtraction | A diff adds 40 lines and removes 15: the net change | A net 25 lines added |
| Division | 12 commits at 3 a day: how many days | 4 days |
02 Lesson flow (45 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0-6 min | Entry check | Ask for the power of two above 600, 114 over 120, the net of 40 and 15, and 12 over 3; keep the answers on the board | Spoken answers, working on paper |
| 6-16 min | Act one: three error types, three ways to hunt | Three columns for syntax, runtime and logic, each with when it surfaces and who reports it | Students say a logic error runs to the end but gives a wrong answer |
| 16-26 min | Act two: binary search, 600 lines in 10 steps | Print a variable at the midpoint or set a breakpoint, halving the range each time; write 512 too few and 1024 enough | Students compute 10 steps |
| 26-36 min | Act three: regression testing and version control | 114 of 120 is 95 per cent; 12 commits at 3 a day is 4 days; a diff of 40 and 15 nets 25 | Students say which commit a rollback should target |
| 36-42 min | Question types with changed numbers | Switch to 900 lines and 138 passes out of 150, then run the four question types | Students do one and write the unit (steps, per cent, lines) |
| 42-45 min | Exit check | Three spoken questions; note which act each error comes from | All three correct |
03 Teaching script (read it out)
Scene 1: Act one: three error types surface at three different moments
A program runs to completion and computes the wrong total: which error type is it, and how would you prove it wrong?
Scene 2: Act two: binary search turns 600 lines into 10 steps
How many halvings does 900 lines need, and why is one print at the midpoint not enough?
Scene 3: Act three: regression testing and version control are two sides of one idea
If one commit changes five things and one of them turns out to be buggy, what does a rollback cost you?
04 Question types and worked steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Classify the error | The program runs but the answer is wrong | Three questions: any message, when it appears, is the answer right | Logic error: runs, no message, wrong answer |
| Design the debugging steps | 600 lines, only input and expected output known | Compare expected with actual, halve the range, then use powers of two for the count | At most 10 steps, since 1024 covers 600 and 512 does not |
| Compute the pass rate | 114 of 120 unit tests passing | Passes over total times 100; subtract for the remainder | 95 per cent, 6 still failing |
| Describe version control | 12 commits at 3 a day, two versions back | Commits divided by per-day pace; rollback names the target commit | 4 days; rollback restores the files to that commit |
05 Independent practice (3 questions)
| Question | Answer | What to watch |
|---|---|---|
| 114 of 120 unit tests pass: what is the pass rate | 95 per cent | Watch for 6 used as the numerator |
| Finding one bug in 600 lines by binary search: how many steps at most | 10 | Verify with powers of two: 512 short, 1024 enough |
| A diff adds 40 lines and removes 15: the net change | 25 lines added | Do not add 40 and 15 together |
06 Common mistakes and what to say
| Mistake | Student writes | Say this |
|---|---|---|
| Treating a logic error as a syntax error | Answering that with no red message the program is correct and the input must be wrong | A syntax error stops the program before it runs; a logic error runs fine and returns a wrong answer, caught only by comparing with the expected output. Confusing the two leaves students stuck at it compiles, so it ships. |
| Printing every line instead of halving | Adding a print to each of the 600 lines, so 600 attempts | Binary search halves the range, so 600 lines take at most 10 steps; line-by-line takes 600, which no exam allows. |
| Skipping the test suite after a fix | Declaring the task done once the one failing feature works, without rerunning the tests | Regression testing exists to prove that fixing one line did not break another. Skip it and the new defect ships, usually harder to trace. |
| Stuffing every change into one commit | Putting three unrelated edits into a single commit | Commits should be small and single-purpose so a rollback is precise. A commit holding ten changes rolls back the good ones with the bad. |
07 Homework (paper, section and question numbers)
- Secondary ICT prep guide: debugging and version control chapter (question types and chapter exercises) — Chapter exercises, questions 1 to 4
08 Exit check (last 5 minutes)
| Question | Answer | Decision |
|---|---|---|
| The program runs but the answer is wrong: which error type | Logic error, caught by comparing with expected output | Wrong: reteach act one, when each type surfaces |
| Finding one bug in 600 lines by binary search: steps at most | 10, since two to the tenth is 1024 | Wrong: reteach act two, verify with powers of two |
| One commit changes five things and one is buggy: what does rollback cost | It removes the good changes too, so commits must be small and single-purpose | Wrong: reteach act three, commit granularity |
09 Tutor FAQ
How does this connect to S3 Python loops and functions?
S3 teaches writing a working program; this chapter teaches finding faults in it. A wrong loop repeats its mistake a thousand times, which is exactly where binary search and tests earn their place.
Is 45 minutes enough for three error types and version control?
Yes, if act one takes only ten minutes. Three columns and one line about timing settle the error types, and the time belongs to the binary-search arithmetic in act two.
Are 120, 114 and 600 real project figures?
No, they are teaching numbers chosen to divide cleanly. Real test counts and debugging times vary widely, and the method and direction of judgement are the point.
Find a tutor — freeTutor Registration →
A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.
© TutorZone · www.tutorzone.com.hk · For personal study and teaching use only.



