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
gjutras#
Make code hygiene your mantra. Piece at a time, make existing code better and make your code obey all the solid clean code principles you care about. If you want to TDD, make artificial seems on everything new and do TDD on the new stuff and start putting tests around areas at the smallest levels you can and start refactoring slowly in areas that you are touching. Make it a process that you always follow to have good hygiene. You'll eventually end up with clean code.
DrBazza#
> 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.

Even the worst projects tend to have logging. You can hook into that, and whilst it's not great, you can test that correct log messages are made.
The TDD book, does in fact step you through examples with no tests and show you how to hook them in.
It isn't quite as hopeless as you think it is. In fact this is the kind of system I quite enjoy working on.

Kiro#
Working with bad legacy code is a big part of being a programmer. Legacy is the single most important area I ask about in interviews. As a medium level software developer you should be completely comfortable working with legacy spaghetti and I'm surprised that you seemed shocked. The reaction you have is typical for junior programmers who haven't yet realised that this is the reality in professional programming. There's nothing unique about your case.
sundaysatan#
Welcome to the industry. If I had a nickel for every code base I came across that gave me nightmares, I'd be able to retire.

Depending on the company, I would just keep my mouth shut. Specifically in corporate environments, where ass-kissing gets you promoted faster than skill level. I've experience this time and time again. I'll go into a company, realize the code base is trash, I'll say something about, and then not couple months later I'll be let go.

Load more comments