The File Everyone Was Afraid To Open

by Serguey Shinder

Every team I have joined has had one. On this team it was a single module, about four thousand lines, that handled pricing. Nobody had written it. It had accumulated. When a change touched pricing, the estimate tripled, and the tripling was never questioned, because everyone had already agreed, without ever saying so, that this file was different from other files.

What I found interesting, once I noticed the pattern, was the shape of the code around it. There were three small utilities elsewhere in the system that duplicated logic from inside that module, each written by someone who needed the behaviour and decided it was cheaper to reimplement it than to go in and use the original. The fear had not contained the mess. It had quietly exported copies of it into places nobody was watching.

I asked why nobody had cleaned it up and got a consistent answer: it is too risky, and there are no tests. Both of those things were true. But sitting behind both of them was something else, which was that no one wanted to be the person whose name was on the commit if pricing broke on a Friday. The technical reason was real and the social reason was doing most of the work.

So I spent two weeks not fixing it. I read it, slowly, and wrote down what each section appeared to do, and then wrote tests that asserted the current behaviour, including several behaviours that were obviously wrong and that I deliberately did not change. The tests were not there to improve anything. They were there to make the file describable, so that a conversation about it could be about facts rather than about how it felt to be in there.

The fixing, when it came, was ordinary. Somebody else did most of it, months later, and it was uneventful, because by then the file had stopped being a mystery and become merely large.

What I took from it is that fear in a codebase is a measurable cost with no line item. It shows up as inflated estimates, as duplication, as features quietly designed around a region nobody wants to enter. None of that ever appears as technical debt in any conversation, because it does not present as a problem with the file. It presents as everything near the file being slightly worse than it should be, forever.

Now when I join something new I try to notice which parts people lower their voice about, and I go and read those first, before I need to change them and before the fear becomes mine. Usually it is not as bad as its reputation. Occasionally it is worse. Either way, the reading costs a week and the not-reading costs a year, paid out in small unattributable amounts that nobody ever adds up.

– Serguey Asael Shinder

Leave a Reply