5
sjwsjwsjw
247d

cant figure out how to refactor legacy code in any clean/acceptable way

Comments
  • 5
    Figure out the behaviors. Write tests to ensure it behaves that way. Start with the easy stuff, end with the important stuff.

    Now start refactoring.
  • 1
    Also block PRs/merges on automated test pipelines passing.
  • 3
    Start SMALL! Broken but refactored code is worse than working but shit code lol. And @lungdart said, write tests, get the general behaviors sorted out and test the general behaviors and functionality.
  • 4
    What happens when the legacy code fails tests it should pass? What if those quirks are relied upon?
  • 2
    i've always regretted being born but it's more intense when this is supposed to be a small & easy ticket
  • 1
    @Demolishun tests? Yeah, right.
  • 1
    @electrineer I am assuming they are going to write some for the new code.
  • 1
    If you can find what code gets called on what situation, it starts to become possible to extract code into functions you can unit test. It’s neigh impossible if it relies on thousands of god objects and their state, but it’s a starting point if you can get to the very smallest possible unit of code.
    Setting the office on fire is a better alternative as well.
  • 4
    Nuking the old code and starting from scratch might be less effort.
Add Comment