Ask HN: Codebase at my work is a complete mess, what should I do?
406 pointsAfter few days/weeks of getting to know the whole codebase I finally moved to a specific project I was suppose to work on and I found out the code is a complete mess.
Often I find parts of code that unintentionally affects other parts of code. Some parts are just copied and left there doing nothing. Even names of classes/variables are sometimes useless and project structure is unintuitive and seemingly without rules. It's spaghetti and relatively big spaghetti (tens of thousands of LOC).
I started "repairing" the project but there're no tests to check whether my adjustments are correct.
I'm so frustrated and depressed by it. The job basically turned into something I hate - I'm just rewriting the code!
The person in charge of this project was working on it alone and from the outside it all looks fine and it's working. So this makes the higher people think that it's all just fine.
I really don't know what to do.
Should I just go and basically say that this person did a bad job? I don't feel very comfortably doing that because (a) I'm a relatively new hire, (b) the person in charge is working there for about two years and (c) I'm much younger than she/he is both professionally and biologically.
I've already made some comments about rewriting it and the response was basically "ok".
Comments (333) 173 threads
Show all comments
Showing thread 46 of 173
The first thing you need to do is get some people on your side, politically. If you just rewrite the code on your own, nobody is going to thank you. You might even look like a terrible employee because you're sure to break a few things, especially since there are no tests to help you.
Be very careful about this.Explain the problems with the existing codebase, and how they're preventing the team from delivering features.
One idea - give them some easy to understand graphs so they can see how much time's being wasted on the spaghetti struggles. Record your time for a week... show them a pie chart of how much time you spend actually implementing new features vs. how much time you spend fighting with the spaghetti.
Come up with a plan. Suggest devoting X% of your time to reducing technical debt and Y% of your time to delivering new features.
Come up with benchmarks to show your progress. Performance benchmarks, productivity benchmarks, anything.
You can explain the bad state of the code without implying that the previous coder did a bad job.
Sounds like they're aware of the technical debt, so that's a good sign maybe? This is, of course, step one after you get approval and before you start reducing that technical debt. =)After all, it's normal for software to accumulate technical debt over time. This is especially common if you have a single coder that is under pressure to deliver a lot of features in a short amount of time. It doesn't necessarily mean he/she is a "bad coder"; maybe he/she was just not given time to refactor and reduce debt.
Good luck!!