Sigh, this one again.
The reason to refactor used to be because you were working in a monolith which had eons of bug fixes and quirks which if removed risked everything.
Well, things have changed, or they are meant to have. We deal with microservices, things which are small, focused, independent and well defined. They are meant to be so cheap to write that the refactor argument has lost the USP it used to have, either that or you have deeper problems that no amount of coding will solve.
It’s funny, I’ve found that my views have done a complete 180 these last years. Once upon a time I’d have gone gun ho into a refactor, but honestly these days I think it’s cheaper to just write it again.
I mentioned something key there, cheaper. Look, I’m not saying never refactor again, I’m saying there is a cost to value equation which whilst once upon a time was favourable to refactor, is now not.
Writing from scratch no longer carries the regression risk either, we should have rafts of automated tests pumping through all those fun scenarios we dealt with before, if a regression gets through then it deserves to and we deserve to suffer for our bone idleness and complete neglect to test the edge cases that cropped up in live.
To conclude, make an informed decision, do the math, and make sure you’re addressing any fundamental culture problems that mean it’s expensive to rewrite.