Live data from Hacker News

Ask HN: Codebase at my work is a complete mess, what should I do?

news.ycombinator.com

41–50 of 346 posts

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#41

There's a book called "Working Effectively with Legacy Code" by Michael C. Feathers which I heartily recommend. I got it a while back when working on a similar sounding codebase and it was very useful. It's got chapter headings like "My Application Has No Structure" and "I'm Changing the Same Code All Over the Place". If your company has a books budget get them to buy it, but I'd personally drop the £35 it costs on a…

This book was written for OP (and many others). It specifically addresses the "there are no tests, what do I do?" concern.

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#43
post #30

Bookmark this page so that 15 years down the line in your career you can reflect on it. You will have delivered a working software product against all odds, under impossible budget and time demands. Finally they let you hire some help and instead of getting busy helping writing tests and refactoring he starts thinking about the best way to throw you under the bus to your superiors.

This should be the top comment. At my company it is amazing how clueless young graduates play politics from day one, while doing no real work other than going from conference to conference and self-promoting on Twitter.

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#44
I am a senior dev managing a large and relatively messy codebase. Let's see if the way I read the situation checks out:

> I've already made some comments about rewriting it and the response was basically "ok".

This means that the person in charge of the code is probably aware of its shortcomings.

> The person in charge of this project was working on it alone

This suggests that probably the codebase started out in a neat form and became messy over time due to understaffing/bad planning/feature creep. There is only so much he/she could do as an overworked single dev having to manage a large system.

Your senior is probably very happy to have another dev helping with this. I wish I had someone helping me. Take it as an opportunity, dealing with legacy is a challenge but you can grow a lot as a developer!

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#45
this was me a few years ago, here's some stuff I learned about diving in to a codebase like this:

- don't be rude but make it clear you think the code is messy and you can clean it up. Explain it to non-programmers in terms of time needed to add new features and the much greater chance of bugs and side effects

- get a few style rules going (do A and not B, group regions/routes/modules -- with only comments at first, if needed) to apply ONLY to new code going in.

- every time you have to touch old code, bring it up to style, even if your changes don't directly address spaghettiness

- slowly (and more confidently now that you're more familiar with the code) refactor parts of the code

- get at least some sort of test structure in there

It'll take a long time but it'll mostly work and you'll probably find it very satisfying. I know I do. Be polite but firm. Believe me that everyone knows the code is a mess and if someone is willing to put in the legwork, every developer worth their salt will respect you for it. You'll have the authority you need to enforce your stylistic choices and the future structure of the code.

Remember above all else, though, that your job is to write working code, not pretty code that developers like. Your goal should be to infect it with order, not tear it out and rebuild it.

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#46

Is it buggy? Is it insecure? Is it slow? If the answers to those questions are no. Then you the problem and you should look for employment elsewhere. You are unhappy in that job, and you rewriting the codebase would potentially make the above questions answer to a YES, inflicting damages in the company. Now, if the above questions have yes as an answer. Talk to your manager, explain how it won't scale, how it is hack…

Somebody fathered a legacy codebase.

All code is legacy, the only code that’s not is the code that’s not written.

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#48

you should ask yourself a few questions. 1. Is this code in production already making profit? 2. How often is this code updated? 3. Is it profitable to fix that code or just to learn from that experience and move on?

If someone is still confused after reading these, ask yourself: Will the profit I gain from leaving this alone allow me to replace the entire module in a larger refactor later?

at the beginning of my career I read somewhere if it ain't broke don't fix it. If that is making money and you can black box it, then do not fix it, for sure you could always add some test around the black box and then move on. Try to create new software outside of that box that reflects the same ideals that you would have put into "refactoring" the "bad one".

Re: Ask HN: Codebase at my work is a complete mess, what should I do?

#49
post #36

Is it buggy? Is it insecure? Is it slow? If the answers to those questions are no. Then you the problem and you should look for employment elsewhere. You are unhappy in that job, and you rewriting the codebase would potentially make the above questions answer to a YES, inflicting damages in the company. Now, if the above questions have yes as an answer. Talk to your manager, explain how it won't scale, how it is hack…

Someone's a bit touchy on this subject. Is there a reason you're using a throwaway to voice this opinion?

Hard to guess their motives but it is easy to click on their username and see that they post a lot from it.
Post reply on HN