by Serguey Shinder
We added it on a Thursday, and we were explicit about it being temporary. A single boolean, wrapped around a new behaviour, so that if anything went wrong in production we could switch back to the old path without a deploy. It was a sensible thing to do. We wrote the flag, we shipped it, we watched the graphs, and nothing went wrong. And then we moved on to the next thing, and the flag stayed.
Three years later I was reading that same file for an unrelated reason, and there it was, still branching, still defaulting to the new path, still carrying the entire old implementation behind it like a room in a house nobody had opened since the move. Nothing had touched the false branch in three years. The code inside it referenced things that no longer existed anywhere else in the system, functions kept alive purely because that dead branch still called them.
What struck me was not the waste, though there was plenty of it. It was the arithmetic. Every flag like that one doubles the number of states the system can be in, and we had not added one flag over those years, we had added dozens, each one sensible on the day it was written, each one temporary in exactly the same way. Nobody could say with confidence what the system would do under any given combination, because nobody had ever run most of the combinations. We had built a machine with more configurations than tests.
The honest reason the flag survived was that removing it had no deadline and no owner. Adding it solved a real problem on a real Thursday. Removing it solved a problem that would only exist later, for someone else, in a form that would be hard to attribute to us. So it sat there, costing a small amount of clarity every single time anyone read the file, and the cost never arrived as a bill anyone had to pay at once.
I have come to think of temporary code as a loan rather than a favour. Taking it out is fine, often correct, sometimes the only responsible move. But a loan with no repayment date is not a loan, it is a slow transfer of debt onto people who did not agree to it, and the interest is paid in confusion by everyone who reads the code afterwards.
So now, when I add something temporary, I write down what has to be true for it to be removed, and I put that condition somewhere a person will actually see it. Not a comment nobody reads. A ticket, a date, a name. The flag itself is not the problem. The problem is a piece of code whose whole justification was that it would not last, quietly outliving everything around it because no one ever agreed on when it should die.
– Serguey Asael Shinder
Leave a Reply