When I start over vs when I refactor
A test I run on myself before I commit to either path.
Most of the time I refactor. Occasionally I start over. The two temptations are usually present at the same moment, and I have a small test I run to decide which one is right.
The test#
I write down, in one sentence, what is wrong with the current code. If the sentence is about a structural assumption that I can no longer name clearly, I start over. If the sentence is about a missing concept that I can add inside the existing structure, I refactor.
The trap is asking myself which would be more fun. That answer is always "start over," and it is almost always wrong.
What "start over" actually looks like#
I start over rarely, and when I do, I move slowly. I keep the old code running and write the new alongside it. The cut happens last, sometimes weeks later. A start-over is not a deletion event; it is a parallel construction with a switchover at the end.
What I learned from getting this wrong#
I have started over when I should have refactored, and lost two months. I have refactored when I should have started over, and lost six. The second mistake is the bigger one. But the first one is the easier one to make without noticing.