| Hello HN, just wanted to put this discussion out there again to help me (and potentially others) to get a more professional judgement of crufty software projects. I think "This codebase is bad, I could do it better from scratch" is a thought most of us had sometimes in our professional carreer, ironically more often as a young inexperienced programmer than later in your career. I guess that comes with a better understanding of the vast complexity of a software project, the respect for value-producing software in production and a less ignorant assessment of your own abilities. Now I am much more reserved to propose a rewrite. However I recently adopted a codebase (and a team) that made me think: When is a legitimate point reached where a rewrite would be actually justified? I worked with it 3 months now and realize: * There is a substantial amount of Hotfixes from apparently inexperienced programmers (mutable global state, arbitrary waiting statements to battle race conditions)
* There is some business requirements that became obsolete (abandoned views, commented out code with no explanation)
* A whole bunch of skipped test suites
* Two outdated libraries, each of which would demand a very substantial refactoring (vue2 with class decorators -> vue3, dropping of vuex as global application storage)
* Generally a missing pattern on how to organize API access, it's pretty much all over the place What I'd like to hear of the experienced people in this community: Did any of you faced a similar situation with a bad codebase? Which steps path did you go? Rewrite or itearative refactor? How did it go? In retrospect, was it a sane decision? Have you been able to identify markers, or a threshold were rewriting were actually the better decision? Happy new year to everyone and thanks ahead! |
1. Writing code is easier than reading code.
2. When a team is "scared" of their codebase, everybody becomes frustrated and confused and nobody takes responsibility for anything.
The difficult question is _how_ to rewrite. Here are some strategies I've seen in the past:
- The "slow" rewrite: Rewrite a chunk of the code that can be completely rewritten in 2 weeks. Deploy tiny rewrites alongside everything else. New code should not reference _any_ code from the old codebase. Do not try to fix anything in the old codebase.
- The "frodo" rewrite: Ask 2-3 devs to go off on an adventure and rewrite the entire app from scratch while the rest of the team maintains the existing app.
- The "YOLO" rewrite: Give the whole team 3 weeks to rewrite the entire thing from scratch. Put 1-3 devs on "cleanup" duty, where they polish and test the YOLO code before release. Also consider doing some group "bug bashes".