Live data from Hacker News

Ask HN: Started a new job and their existing code sucks. What to do?

news.ycombinator.com

1–10 of 66 posts

Ask HN: Started a new job and their existing code sucks. What to do?

#1
How do you guys deal when you start a new programming job and the company's existing code needs a full refactoring (or to be totally rewritten)?

I started this new job and the current code is so spaghetti that it's almost an Italian restaurant. No good practices are being followed, there are no tests, huge components that should be modularized, no organized architecture at all.

The current developers working on that code aren't very experienced and, even though they acknowledge that some refactoring is necessary, they don't think that's a priority (and that we should focus on bug fixing). However, the thing is so messy that they've been spending the last few months just bug fixing - while refactoring the code would have solved most of their problems.

What would you do? Just don't care and keep doing what you're told to do (bug fixing/closing Github issues) or actually starting refactoring (or rewriting it - sometimes I feel an urge to rewrite the whole thing from scratch) on your own?

This is my first time starting a job with such a bad existing code, so I have no clue about how to proceed. I'm just feeling very depressed having to work on that everyday. :/

Re: Ask HN: Started a new job and their existing code sucks. What to do?

#3
First is it a priority? What are the business goals you're trying to accomplish? Do you have the resources to hit the business goals while some are working on a rework? Pretty code doesn't make a good business.

Talk to your boss. If you feel strongly it needs to be done, explain why, and what the benefits are. You need to be able to quantify and qualify this so do your homework and sell it.

Contrived example: Hey Manager, we've broken this experience 12 times in the last year, so I'm writing unit tests for it, so we can't do it again without knowing. It will take me an extra few hours on this issue but the payoff should be worth it. I think we should do this for everything.

In the meantime, leave everything you touch better than when you opened it. Start teaching the practices you want to see.

Re: Ask HN: Started a new job and their existing code sucks. What to do?

#9
post #7

I would try and clean up the bits I was working on. This is a good book on the topic refactoring a large code base with no tests. https://www.amazon.co.uk/Working-Effectively-Legacy-Michael-...

Thanks for the tip! I'm gonna have a look at it. :)

Re: Ask HN: Started a new job and their existing code sucks. What to do?

#10
You gotta understand that this is pretty much the case at a LOT of places. In the beginning, you should be humble, at least for the first few years. Once you're the most senior person there, say in 5 years, you'll have a lot more political power to do the things you think are right.

And as far as refactoring goes, take things 1 part at a time. Don't try to refactor everything all at once.

Post reply on HN