NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Reasons Not to Refactor (thoughtbot.com)
lelanthran 2 days ago [-]
Simple and brief rules are more successful in practice than long and complicated rules.

I feel a briefer and more-to-the-point "When To Refactor" guide is to ask the following questions in the following order and only proceed when you can answer YES to every single question.

1. Do we have test coverage of the use-cases that are affected?

2. Are any non-trivial logic and business changes on the horizon for the code in question?

3. Has the code in question been undergoing multiple modifications in the last two/three/four weeks/months/years?

Honestly, if you answer NO to any of the questions above, you're in for a world of hurt and expense if you then proceed to refactor.

That last one might seem a bit of a reach, but the reality is that if there is some code in production that has been working unchanged for the last two years, you're wasting your time refactoring it.

More importantly, no changes over the last few years means that absolutely no one in the company has in-depth and current knowledge of how that code works, so a refactor is pointless because no one knows what the specific problems actually are.

andrei_says_ 2 days ago [-]
These are very simple and clear and confirm my own approach to refactoring. Thank you.
karmakaze 2 days ago [-]
I have one reason to refactor that's served me well. Does the code exhibit ongoing edge/corner case bugs, which are attributed to the implementation not being factored in the first place? Another sign of this situation is exhaustive test cases which combine factors as they can't reliably be tested in isolation. Distributed logic is another common pattern, where a new feature is made by sprinkling bits of logic here and there, just so, and it all seems to do what's required. You know the kind, where onboarding a new person might lead to the discussion of how this section of your Rube Goldberg contraption works. A fancy way to this world is a poorly designed and maintained home-grown DSL.

Continuing to build on such a 'foundation' is madness that spirals to code red situations: stop-the-world, no feature development, until shit gets stable.

darioush 2 days ago [-]
another reason to not refactor is management will start out supportive of it but some weeks in they will wonder wtf their engineers are doing all day and why aren't they building the new pile of stuff they want built yesterday.
gavmor 2 days ago [-]
Well, yeah, that example decreases symmetry.[0]

0. https://bensguide.substack.com/i/144306439/local-symmetries

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 01:46:19 GMT+0000 (Coordinated Universal Time) with Vercel.