by Serguey Shinder
I went back into a company I had worked at a decade earlier, as a contractor, for something unrelated. On the second day I opened a file to understand how an integration worked and found my own name in the header, above code I had written in 2014 and could still read.
There is a particular vanity available in that moment and I enjoyed it. Then I looked at what had actually survived, and the sorting was not flattering.
What was still there was the dull part. A file of small functions that turned their supplier's peculiar date format into ours, named after exactly what they did, with a comment explaining which supplier document each rule came from. Four of the rules had been edited since, clearly by different people at different times, each edit sitting quietly alongside the others.
What was gone was everything I had been proud of. There had been a plugin architecture so that new suppliers could be added without touching the core, with a registry, a lifecycle and a small amount of reflection. I remember explaining it at a lunch. It had been removed in 2016. What replaced it was a switch statement with eleven cases in it, which is uglier by every measure I believed in at the time, and which anybody can read in thirty seconds.
I tracked down the person who did it, who now runs the team, and asked. She was pleasant about it and completely unapologetic. They had needed to add a supplier urgently, nobody left in the building understood the registry, and the safe move was to replace the part they could not reason about with a part they could. The switch statement has been edited perhaps thirty times since and has never once broken.
The lesson is not that abstraction is bad. It is that I had optimised for a future in which someone understood my design, and the dull code had been written for a future in which nobody understood anything and just needed to change one rule on a Friday. Only one of those futures turned up, and it turns up every time.
That reframed what I think I am building. On a long enough timeline the reader of your code is a stranger under pressure, with no access to you, no interest in your reasoning, and a specific small change to make. Everything that helps that person survives. Everything that requires them to hold your model in their head gets deleted by someone perfectly competent who has better things to do.
So the question I ask now is not whether a design is elegant. It is what happens to this when the last person who understands it leaves. The honest answer for most clever things is that they get ripped out, and the only real question is how much damage that does on the way.
– Serguey Asael Shinder
Leave a Reply