Refactoring isn't always worth it

January 22, 2024

In the minds of many developers, refactoring sub-optimal code is always good. In my experience, that's false.

Refactoring isn't always worth it. Knowing when to refactor is a skill you can get better at.

The refactor might not be worth it if:

  • It'll take a ton of time/work for minimal improvement
  • The code is working & you just have a preference for it to be "nicer"
  • It's in an arcane part of the code that's rarely touched

I know I just wrote about how you should always strive to leave the code better than you found it. But that post was about tidying up, not totally rearranging the place.

Unfortunately, I've seen many times where developers (even quite senior ones) go rogue on refactoring side quests that suck their energy & the team's focus.

Don't get me wrong... Sometimes a refactor is SUPER worth it. But before you undertake a refactor, try to be clear eyed about the cost-benefit of doing so.


Profile picture

I write something new every day for 2k software developers. You should sign up for the daily email.

© 2024