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?
Top comments (6)
先写预期再跑结果这个习惯我很认同,之前查 bug 时经常是改完才想结果对不对,反而绕了远路。让我想起以前做实验记录也是这样,先写假设再动手,定位问题快很多。
The lab notes comparison fits well. That's actually why I frame the class as an IoT research class. Having a hypothesis before touching anything saves a lot of detours.
the gap between the guess and the result is what you investigate. faster than rereading all the code.
Glad that line stood out. Once you know what you expected to see, you stop rereading the whole thing and look straight at what actually diverged.
That’s the part I’d teach first: write down what you expect before you run it. On an Arduino, that might just be “the LED turns on when I press the button.” If it stays dark, printing the pin value tells you which half of the problem to look at.
Exactly. Without printing the pin value, a beginner only sees "LED stayed dark" and starts guessing across the whole board. Seeing the reading splits the search in half: either the input never arrived, or the output side broke.