How do you safely clean up legacy code without breaking hidden dependencies?

by•

Cleaning up technical debt feels satisfying until you realize that mysterious piece of ugly code was actually holding the whole feature together.

I used to delete anything I didn't immediately understand during a refactor thinking I was being efficient. Now I've learned the hard way that messy code doing vital work looks identical to code doing nothing at all if you don't check git blame first.

What's your current routine before you hit delete on a large block of legacy code?

14 views

Add a comment

Replies

Best

I'd check references outside the source tree too: scheduled jobs, config strings and older clients. A quiet code path may only run at month end. Keep the removal in its own reversible change so a missed caller doesn't force you to undo the whole refactor.