WSWhat Scene?

Learn · Development dos and don'ts

When should you rewrite code versus fix it?

Usually, improve what you have (refactor) rather than starting over (rewrite). Rewrites are tempting but risky: they throw away years of fixes and edge cases, take longer than expected, and often recreate the same problems. Reserve a full rewrite for when the foundation genuinely can't support what you need.

Refactoring improves the code's structure in small, safe steps while keeping it working, which is lower risk and delivers value continuously. Most "we should rewrite this" urges are better served by steady refactoring, backed by tests so nothing breaks.

A rewrite can be right when the technology is truly obsolete or unsupportable, or the requirements have changed so fundamentally that the old design fights you at every turn. Even then, the safer path is often to replace piece by piece rather than all at once.

Updated July 2026

Related

Want this built, not just explained?