My sonar said the lake was zero meters deep. It was not.

This week I built Sonario, a phone app for a small sonar device you use from a boat. The sonar streams readings over its own WiFi, and the app draws what is under the boat.
The best bug of the week was one number. Just one. Now and then the sonar sent a depth of zero. Zero does not mean the bottom is at the surface. It means no bottom was found. Read it as a real depth, and the screen shows the lake bed rising up to meet the boat!
Where did I find it? At my desk, in 5 seconds, not on the water. Here is how.
Why a sonar is slow to build for
Every change needs the device. The device needs to be in water. Your phone has to join its WiFi, so you have no internet while you test. So how long does a 5 second test take? 20 minutes and a trip outside. Do that 100 times and the week is gone. Unless you bring the lake to your desk.
The two hours that paid for the week
So on Saturday morning, before I wrote any of the app, I recorded the sonar. Real water, real readings, saved to a file exactly as the device sent them. Every broken line. Every dropout the hardware makes.
Then I wrote a small replay service that pretends to be the sonar and plays the file back at the same speed. From then on, everything was built at a desk. Can Sonario tell the difference? No! The replay sends exactly the same data, broken lines included.
$SDDBT,7.20,f,2.20,M,1.20,F*30
$SDDBT,5.70,f,1.74,M,0.95,F*3A
$SDDBT,1.06,f,0.32,M,0.18,F*39
$SDDBT,0.00,f,0.00,M,0.00,F*36
Real depth lines from the recording. The number before M is the depth in meters: 2.20, 1.74, 0.32, then 0.00. That last one is not shallow water. It is "no bottom found".
The rest of the week flew. No ready made plugin could read the sonar's data, so I wrote one for the phone. In one afternoon, because I could try things right away.
The rule: record reality, don't simulate it
Why not just make up test data? I could have, in an hour. It would have been worse than useless. Made up data has the shape of what you expect: the fields you remember, the format you assume, the ranges that sound reasonable.
A real recording has what you did not expect. A line cut in half. The same timestamp three times in a row. And a depth of zero that means "too deep to see".
Each of those broke my code at the desk, in 5 seconds. None of them broke it on the water. That is the whole trick.
How to do it on your project
The same trick works for anything slow or out of your hands: a payment provider, a device, a partner's system, a long job.
- Record the raw data. Exactly as it arrives, not your program's tidy version of it. You are going to change the code that tidies it.
- Record a bad session on purpose. Pull the cable halfway. Let a request time out. Those files are worth more than the clean one.
- Replay at real speed. A replay that runs too fast hides every timing problem.
- Make it one switch. The same code runs against the device and the replay. Nothing is written just for the fake.
- Keep the recordings next to the code. They will outlive it.
What the zero taught me
The sonar was not lying. It was saying "I don't know" in the only way it could. The mistake would have been mine: I would have taken a missing answer and drawn it as a real one, with full confidence, on a screen people trust on the water.
I think about that zero a lot now, working with AI. A blank and a zero look the same in a column of numbers. Machines and people both fill silence with a guess and then forget it was a guess. Fake test data does exactly that. It fills the gaps with what you already believe, so your code passes and you learn nothing.
A recording does not care what you believe. It is the world, saved to a file. That is why I go to it first now. Not because it is clever. Because it is the one test input I did not write myself.
Things I did not expect
The first surprise was how messy a real stream is. On the water, half a line or a timestamp sent three times would be a crash I could never repeat. In the recording? There every time, at the same second, waiting for me. A bug that waits for you is a gift!
The second surprise was the browser. The plugin I wrote only works on a phone, so in a web browser Sonario talked to the replay instead, over a WebSocket. Wow. The replay I wrote to save trips to the water turned into a second way to run the whole app.
And the recordings outlived the code. I rewrote the part that reads the stream twice. The files never changed. They are still kept next to the code, the most trusted thing in the project.
My week was fast because on Saturday I spent two hours making the rest of the week cheap.
I post one of these every week. Follow along on LinkedIn or YouTube, or by RSS. Want this on your team? Work with me.
The 527 rules I give my AI agents, free
Every one comes from a real mistake. The best 100 are open on /rules, or download them as AGENTS.md, no email. All 527 come by email, as one file you can drop straight into your repo as AGENTS.md or CLAUDE.md, so your agents follow them from the next session. Plus the occasional email when I learn a new one.
One click to unsubscribe.