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
Earlier commentsI joined a small company 8 months ago. The code at first felt somewhat sane, but the more I worked with it the more I understood that the whole project is a huge copypaste mom's spaghetti. I started rewriting everything I "legally"(somewhat within the scope of my tasks) could. I also kept asking the lead coder about the poor quality and poor decisions up to the point where all we did was argue. Management saw this and it turns out they were not satisfied with his performance for quite some time. He gets kicked out(after 4 years). During the 8 months I have deleted 1/3rd of the whole codebase, replacing it with much better code both quality and performance wise. I did that because I don't want to spend the next couple of years suffering from someone's bad decisions and complete lack of experience. Now I get to work on much more interesting tasks, everything gets delivered faster. Some of the stuff I wrote gets used across other teams. Only things that still keep me getting stuck in debugger are those I haven't rewritten and everyone agrees we have to rewrite them in near future.
I know I made a risky decision, but it was well worth it.
Is it typical to be able to look at a company's code before signing up? After having a similar experience, I wish I could make that a standard part of my interviewing process. (Brief backstory: I would never in 1000 years have taken my first development job if I had seen the code first, but HR and the carefully selected engineers who could tell positive stories gave me a false impression of what was going on.)
We now have to demand to see the codebases we are going to work with/against first. Even if we only touch the API in some cases; if the API is built on quicksand then we risk spending a lot of time building something that is not viable but that might not be immediately clear.
I guess it is not typical, but at one company I interviewed for I had a day for implementing something (a small feature and some unittests) which allowed me to check their codebase. I liked what I saw and worked there for some months.
Start here. Start writing tests. Lots of tests. This is part of what makes it engineering and not just craftsmanship.
Once you have enough code coverage (this will take a long time), start rewriting small parts of the system. You will have your tests to fall back on to verify you new design is correct. For each part of the old system, once you are confident, replace with your new code.
This all needs to be communicated up front as a long term goal. It's not about a rewrite. It's about the tests and having high quality software.
Something you need to understand, they may not want or need high quality software. Quality costs money. Sometimes good enough is all they can afford right now, even though we know the tech debt will accumulate interest. A part of your pitch is to communicate how important quality is to the long term viability of the software.
All comments shown.
Couldn't load more comments. Check your connection and try again.