Catalin Bozianu

The redraw test

Last week I built a pipeline that takes a list of videos, pulls the transcript, picks the segments worth keeping, generates a voiceover and assembles the result. Five days. Ninety three commits, forty nine of them on the Friday.

I had never written video processing before. Never used a text to speech API. Used a headless browser maybe twice.

The speed is real and I am not giving it back. What I had to invent, fast, was a way to keep the speed without ending up as the owner of code I do not understand. Here is what I landed on.

The redraw test

Before I accept a piece of code, I close it and ask whether I could draw its shape from memory tomorrow morning. Not the syntax. The shape: what calls what, where the state lives, what happens when it fails.

If I can, it goes in. If I cannot, I do not read it harder. I ask for it again, smaller, as two or three pieces with names, and run the test on each.

The reason this works is that it is a test of the code, not of my attention. A module I cannot redraw is usually a module doing three things, and asking for it smaller fixes the real problem rather than my understanding of it.

Why plausible is the dangerous output

The failure mode here is not bad code. Bad code is easy, it throws.

It is code that runs, handles the happy path, and contains no thinking. Twice this week I accepted something that worked and later found it worked by accident. Both times there was a test. Both times the test was testing the wrong thing, because I had asked for a test instead of deciding what the test should prove.

So the second habit: I write the assertion myself, in words, before anything is generated. One sentence. "Given a transcript with no punctuation, the segmenter returns at least one segment." Then whatever produces that test has a target instead of a vibe.

The three questions that catch most of it

Over those five days these are what kept turning up real problems.

What happens the second time this runs? Most generated code assumes a clean first pass. Re-running is where the duplicates, the double charges and the corrupted files live.

Where does this fail loudly? If I cannot point at the line that throws when the input is wrong, there isn't one, and the failure will be silent.

What did you choose, and what else was available? Asked directly, you usually get an honest answer about alternatives, and about half the time the alternative was better and got dropped for no reason.

The actual takeaway

Speed is not the thing you trade away for quality here. The thing you trade is depth of attention per line, and that one you have to buy back deliberately.

The redraw test is what I use to buy it back. It costs about fifteen seconds per module and it has stopped more bad code than any review process I have ever been part of.

Back to the diary