What seven 8th graders with an Arduino taught me about debugging
Every Thursday I teach an IoT research class to seven 8th graders. We use Arduino Uno and PictoBlox, over 12 meetings.
The sentence I hear most is "it doesn't work". Almost every time, the cause is one small step that nobody checked. So I stopped explaining the whole system at the start.
A student begins with one blinking LED, changes one thing, and says what they expect to happen before they press upload.
The loop
- Start from something that runs.
- Change one thing.
- Write down the result you expect, then run it.
If the result differs from the guess, the gap between the two is what you investigate. That is faster than rereading all the code.
Where I use it now
I build web apps with Laravel and Astro. The same loop shapes how I review a pull request and how I help someone new find their way around the LMS my team builds at ABhome Education.
A reviewer who says "I expect this to return an empty list when the user has no enrollments" gives the author something to check. A reviewer who says "this looks off" does not.
A small example:
// Expectation first: a student with no enrollments gets an empty collection.
$courses = $student->enrollments()->with('course')->get()->pluck('course');
dump($courses->isEmpty()); // expected: true
This is a generic sketch, not code from our LMS. The point is the comment above the line, not the line itself.
Question for you
Which habit from outside engineering made you better at your job?
Comments
No comments yet. Start the discussion.