Lurker News
Recently I joined a relatively small company (50-100 employees) as a medium level software developer. For a while I was very excited about this opportunity.

After 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 comments
expertentipp#
> The person in charge of this project was working on it alone and from the outside it all looks fine and it's working.

There is a reason things are like this. One thing are "best practices", blogs of design patterns advocates, interview process, and smartass community celebrities. Another thing is real professional environment with business reasons, limited budget, and limited personnel.
> Should I just go and basically say that this person did a bad job?
It will not impress anyone. It's not a job interview where one can smear, judge, and reject the candidate for the most trivial nuance. It's your daily job and you'll have to work with these people.
Rewriting functional application during the first months of employment doesn't sound like a good idea. Use cases, edge cases, algorithms - probably took good time to figure it out. Just think about it - the last guy trying to do it ended up alone, dumping the whole codebase on someone else.

JohnBooty#
I've been there. Lots of times!

    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?
It's not easy but it's possible.

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.
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.

    Should I just go and basically
    say that this person did a bad job?
Be very careful about this.

You can explain the bad state of the code without implying that the previous coder did a bad job.
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.

    I've already made some comments about rewriting it and the
    response was basically "ok".
Sounds like they're aware of the technical debt, so that's a good sign maybe?

    I started "repairing" the project but there're no tests to check whether my
    adjustments are correct.


This is, of course, step one after you get approval and before you start reducing that technical debt. =)

Good luck!!

Yokohiii#
Welcome to software engineering, this is how things are here. It is very unlikely that you will ever work on a large project that gives you a warm feeling in your belly. So learn to grow on it.

Rewriting random code as a codebase newbie is always a mistake. You will get things wrong. Mistakes can be delayed a long time before you are aware of it.
Try to understand the product. You should spend more time to understand the product features and flow instead of staring at single ugly code fragments. Understanding it will reveal some structure in the code, even if it isn't explicit. Try to engage your peers about things you don't understand. They will potentially deliver tons of detail and background information. Over time you can mentally map this high level information to the codebase.
If you understand the product better, I'd suggest to write a few (1-5) simple selenium tests that cover the core tasks of the product. This test is simply to ensure that you do not break something on the greater scale and the product is still delivering it's basic value. If you start to find confidence with you tests, you can share them with your peers. This will give everyone some instant value and potentially a lot of respect towards you.
You seem to be afraid of your colleague. You don't even know if he wrote all that code, you don't know about his stance on the codebase. Engage him, try to find out how he is working with the codebase. Try to find out his skill level and mentality. Do not judge early, don't complain. Even if he is low skilled, he could have a lot of knowledge about the product and the company.
Eventually don't expect to rewrite the whole codebase. Rewriting a large valuable project which is in production will take easily a year. One year after that someone will claim this is legacy. It won't help. It is easy to think that you can do better, but even a clean codebase can be a huge mess. Figure out how to gradually improve the project alongside features. Figure out risks and high friction tasks for devs, operations and users.

salty_biscuits#
Write lots of tests first, fix the code as they break. Don't make it personal for the people who wrote it. You don't know the conditions under which they originally wrote it. All else fails, join a start up early and write a whole bunch of shitty code in an existential panic.

Load more comments