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
MetalBuddha#
The hard truth is, you're best leaving it alone unless you're willing to take the flak for introducing bugs into "working" code. It's just one of the unfortunate realities of software development.
groestl#
This thread is full of valuable advice, and you should probably bookmark it and read all of it again at times. But if I had to pick a single advice as the most important one: lose the term "rewrite". It's way to easy to get a deadline or time budget attached, and that's a very bad place to be in, especially if people start to think the rewrite stalls regular development. Improving an existing codebase is not a task, it's a process. You make it part of your everyday routine, deliver features on the way, and your budget for improvement is virtually unconstrained.
hermitdev#
I'm in a similar situation (small company, less than 50 employees, 4 engineers on the core system), but I feel fairly comfortable tackling it as I've done similar work in the past - basically rewriting from within. For me, key is dont throw it all away and try and start from scratch. Do the rewrite from within. Identify problem points and tackle them one at a time. Try not to get too ambitious. Try and keep the scope small. Doesnt always work, though. Thought I started a small scoped change a few months ago, ended up with a +600 file commit, the code was that tightly coupled.
monkeybutt#
Install phabricator somewhere if you are allowed to. Use it to add comments/reviews to the code, for now for yourself but later maybe to share with the team. Create a branch to add your code changes toto, except for the tests that you are adding to the main branch.

Remeber, code is the embodiment of business rules. Often business are not aware of the rules until after thing work incorrectly. Non-beautiful odd can be the result of programmers dealing with the messy realities of trying to satisfy various stakeholders who are at odds with each other and can't articulate what they need.

Load more comments