Live data from Hacker News

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

news.ycombinator.com

161–170 of 346 posts

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

#161
post #32

Earlier quoted context omitted.

Only successful applications have the pleasure of getting old.

"Successful" by literally any measure.

Success, in this context, means having solved some problem for a meaningful length of time.

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

#162
If there is no tests to back you up, that's where I'd start.

I work in a similar company in the past, and having tests / a build server is step 1 to empower other to refactor more. The lack of tests is usually what brings people to paralysis / creep / huge tech debt ime.

And don't forget that beautiful code is not actually necessary for business. What is needed is delivering value to your users in a consistent manner. Well structured code will be needed if the project is here to last in the long run, but it is not always the case.

As far as I can read, you're doing great. Keep it going and other are likely to look up on you in the future, and you'll grow a lot.

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

#163
Start with writing Unit tests for basic functionality.

Do not do the cardinal sin of writing unit test for every goddamn function in the codebase like a rookie.

Start fixing code, one by one only if it can be tested by Unit tests.

Remember you need to first learn the code base and context because harping "complete mess". Maybe they did not have time, maybe timelines were more imp. That is what industry is about especially when you do not have enough Engineers. Plus this new wave of PMs who want features at any cost, doesn't make things any easy.

Good luck

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

#164
If the original developer is still around, have some informal chat here and there on why the worst part are the way they are.

Frame it correctly: "I don't understand why these classes share this data or code, do you remember why?" is miles better than "Explain me this mess please it's making me crazy"

If the original dev is still around focus on the task that come from business so he's free to focus on fixing the structure, he is, after all, the local expert on it.

In general a rewrite is not something you'd do without having a clear understanding of the requirements. What you can do instead if you don't have the dev support is to fix thing as you go, removing cross dependencies and encapsulating behaviors. You don't have to fix code only to hide the ugliness behind a clear structure and as small as possible interfaces, order will eventually emerge.

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

#165
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!!

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

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

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

#168
I've been on both sides of this issue in the span of my career. I've joined companies with absolutely horrific code, and I've hired people who thought my code was shit.

My advice is don't complain and don't attempt any significant rewrites for the first 6 months or so. Your job at first is simply to understand the code and demonstrate that you are able make improvements to it without breaking everything. Doing so will win you the trust and respect of your teammates, whereas if you come right out of the gate trying to rewrite everything there is a very good chance you will make yourself look like an ass by spending a lot of time and energy introducing bugs into a previously-stable area of the code. Once you have a decent understanding of how and why the code is the way it is, and the trust of your teammates, then you can invest effort into fixing the highest-priority issues with the code.

Being able to read and work effectively in legacy code is an essential skill for any software engineer. For now you should just try to focus on fixing bugs and implementing new features, and take pleasure in the fact that you are improving the project and developing a handful of hard and soft professional skills.

That being said - there should be a limit to how much bullshit you put up with. If after six months to a year you still find that you hate the job, and a better opportunity comes along, then go ahead and take it.

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

#169
Like it or not, it is your responsibility to inform management if/when there’s a problem. It is their responsibility to decide what to do about it. Be transparent about the impact that the current codebase is having on your estimates, bugs in your code, and job satisfaction. Analyze the situation and offer solutions. If you have provided management with accurate information, you will have no reason to feel bad about the outcomes, and there should be no surprises for anyone.

I understand that you do not wish to offend your coworker who wrote poor code. That’s good, but it is also your responsibility to find a non-offensive way to communicate when their work is not ideal. I recommend using “code-first” language when talking about the code. For example, do not say “what you’re doing in this function is wrong”, say “this function is incorrect” (basically just never say “you” when discussing the code.) If they get defensive, remind them that your goal is code quality, and that you are not trying to be offensive. Be precise, informative, and most importantly: humble.

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

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

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

Here's what actually happens.

By that point in a project's lifecycle, that's not what they usually ask of the new hires. People are usually tasked with fixing bugs/maintenance, and implementing new business logic. Both of which are extremely challenging and stressful when working on a project that comes with no tests, or documentation.

Your actual task as the new hire is to start generating more value for the company, but that's so much more challenging when you have no way of validating your solutions, no infrastructure to rely on, and no metrics or documentation to consult. At that point, being the new hire, you're taking a lot of heat for not getting things done on time - mostly through no fault of your own. At that point, "wanting to throw you under the bus to your superiors" is a very natural response - it's a defense mechanism, you're (rightfully) frustrated. You're between a rock and a hard place. At that point you're no longer doing software engineering, it turns to politics/coverups/fire-extinguishing on a daily basis. Can you not relate to that?

Post reply on HN