We’ve all been there. You inherit a codebase that’s horribly architected, riddled with technical debt, and coughs up blood if you so much as look at it. Or perhaps, there’s still life in your software, but it needs some heavy physical therapy and medication to get it healthy again. In either situation, the words refactor and rewrite will inevitably surface. What causes a refactor or rewrite? Are refactors always bad? What happens if large refactors are needed, but aren’t done? How can big refactors and rewrites be avoided in the first place?