Founder Notes
Dead Code Is Not a Design Document
I wrote the brief for this one myself, and the brief contained the wrong fix.
The bug was small and real. Publishing a record in our system is supposed to flip two flags: one that makes it live, and one that marks it as no longer a draft. The path real traffic went through flipped the first and left the second alone, so a published record stayed marked as a draft indefinitely.
While tracing that, I found a function that did the job properly. It set both flags, together, in the right order, with the validation in front of it. It had no callers — not one, anywhere in the application. Dead code.
So the brief I wrote said: route publishing through that function.
Why the dead function was persuasive
It was whole. That is the entire reason.
Three paths in that service could put a record live, and each of them did part of the job. The unused one did all of it. From that it was easy to assemble a story: somebody had written the correct version of this operation, nobody had wired it up, and the live paths had grown as ad-hoc substitutes that each forgot a different half. On that reading the repair is obvious and almost moral — stop the drift, route everything back through the real implementation.
The story was coherent. It was also wrong in the one part that mattered.
What was actually different
When I finally read the paths side by side, the live one already ran the same validation. Same function, same checks, called at the same point in the sequence. Every piece of enforcement I had imagined I would gain by re-routing was already running on the path that handled all the real traffic.
The entire difference between the dead function and the live one was a single assignment — the one flag.
So the change I had proposed amounted to this: move all production traffic onto a code path that had never served a request, in order to acquire one line I could copy in the other direction in about a minute. The second version is what shipped.
The part worth keeping
Here is what I actually got wrong, and it is not really about the bug.
The unused function looked better than the code doing the work, and I read that as evidence it was better designed. It was not. It looked better because nothing had ever called it.
No caller had ever turned up with an awkward case, so it never grew a branch. No integration had ever needed to skip a step, so it never grew a flag. Nobody had ever needed it to behave slightly differently for one account on one afternoon, so it never acquired the clause that makes a function ugly. It had the clean shape of something that has never been asked a question.
The live paths were messier, and most of that mess was a record of use. Some of it was certainly junk. But I had no way to tell which was which from the outside, and I did not try — I took the tidier thing as the intended design and built a plan on it.
The generalisation
The cheap check I skipped: before proposing to unify two implementations, read them next to each other. I had assumed the difference was the enforcement — the thing that would have justified the whole change — and I never confirmed it. One minute of reading would have produced the one-line fix on the first pass instead of the second.
But the habit underneath it is the part worth keeping. Tidiness tells you how much use something has survived. It is weak evidence about how well something was designed, and the two are easy to confuse, because the thing that has never run is also the thing that has never been made to compromise.
So when you find an unused path that looks like the correct version of what your system actually does, the gap between them is a question, not an answer. Usually the answer is dull: the live code grew those branches for reasons, and the clean one never had to be true about anything.