Or, why starting a major refactor at 10pm is never a good idea.
I’ve done it once too often. I’m sitting there at the end-end-end of a productive day’s coding, and suddenly I have a revelation, some stunning architectural insight that gleams with simplicity, the polished smooth lines of its design making my current implementation feel like some kind of Baghdad construction site. It’s as obvious as it is elegant. And it must be implemented. Now.
And so, ignoring my better judgement, the Samurai is unleashed, ploughing into a major refactoring at 10pm.
The shiny IDE with all its single-keystroke refactoring smarts is the Samurai Coder’s weapon of choice. I have mine wired to my favourite Emacs key-bindings. Its razored blades project destruction with the flick of a finger – slicing and dicing large tracts of code with the merest thought.
So there I am, in my own Kill Bill sequence of large-scale dismemberment as I render radical surgery to the code base. Classes dispensed with, renamed, repackaged. Members pushed up, down, out of existence. Mass graves for the disappeared. Nothing can hide from option-F7, “Find Usages”.
The ripple of destruction spreads relentlessly outward, until I find myself in unfamiliar territory – code I haven’t seen in quite a while. The Samurai sheds his first beads of sweat. It’s midnight. Behind me the code base lies flayed open, filleted and bleeding. The modified file count has hit 40.
No time for reflection. Don’t lose the vision. It’s onwards and inwards.
By 2am the clichéd chirping of the night crickets outside provides a suitable background as the full context of the carnage I’ve unleashed comes into focus. The gleaming vision of architectural purity has faded and been replaced by a vision of red squiggly lines everywhere. Unit test failure on a grand scale.
In the end there were just too many classes. The coupling was too severe; the dependencies too subtle. The Samurai is beaten. The blades of destruction spin down. Not so much Kill Bill – more my very own horror film, The Refactoring.
There is only one course of action left for the true Samurai:
$ svn revert -R .