Live data from Hacker News

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

news.ycombinator.com

181–190 of 346 posts

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

#181
post #62

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…

Is there a chapter on what to do if your coworkers don't initialize variables? I just inherited a steaming pile of legacy where they didn't and I'm struggling to understand how they got it to run at all. At least I'm starting to understand why we held off on the spectre patches.

Not explicitly, no, but it does have some techniques for reading code that might help?

Do you mean global variables? I guess it entirely depends on what language and framework you're using, but trying to refactor things to have less global state is generally for the best.

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

#182
I'm increasingly surprised at how much code I see without comments. Sometimes hundreds of lines without a single comment. And the author seems to act as if it is a badge of honor. "My code is self documenting" or "I know how it works -- it's obvious to me".

Then the author leaves, and management assigns someone else to take over the code, and he/she flails for months. It seems so inefficient. Management prioritizes shipping features over long-term maintainability and tests.

Are comments considered "old school"?

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

#183
post #79

So you're the new guy that's been assigned to this project...possibly at the request of the current developer who desperately needs help...possibly because it's the project that existing staff don't want to work on...possibly to learn the project so the current developer can be moved to other projects. Every software company has these projects and many developers have been in your position. As long as the software is…

> However long you think it will take...double it

... and also don't think that your "double of original estimate" is anywhere near a maximum of what it can take to actually make the code base better and functionally correct.

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

#184

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 wil…

> Being able to read and work effectively in legacy code is an essential skill for any software engineer.

This is key advise. It makes the difference between a person who enjoys the art of coding and a professional who get paid for work. Basically you have to first proof why the invest of rewriting brings any financial benefit. Till then, be professional and maintain it.

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

#185
post #142

Earlier quoted context omitted.

I manage my team. When I discuss projects with my manager and the senior engineering leadership, they will almost always refer to staff as resources, e.g. "team X needs a SOA resource", "team Y needs extra QA resources" and so on. It's distasteful to me; I always refer to my team and other engineers as engineers or by name, not as "resources."

To balance things out, try casually slipping in the word "overhead" when talking about management.

I do that. Does not harm. They know themselves :). Good advice!

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

#186
post #95

Earlier quoted context omitted.

> The fact a new resource (you) has ... I am not familiar with this lingo. Why exactly is the OP a resource? Is this usage of "resource" common in business speak?

Yes. It (being called a resource) is common in Big companies where they literally see you as a "resource". This is worse when you are a 'resource' in a big service company.

No it is not. That is just project management language.

It is the culture of the company who makes the difference.

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

#187
"When all you have is a hammer, everything looks like a nail"

Don't go into the trap of rewriting the code the first week, all new coders think that is the only solution on the first job. It takes time to realize why the code ended up in that state in the first place and badmouthing previous developers doesn't make you look very good. Management might very well know why the codebase looks like it does, priority is often time, not quality.

Something that looks like a bug might have become a feature that the users depend on. If you remove that bug you have created another instead risking corrupting data and/or angry customers not able to do things the way they are used to.

For all you know you are being tested for work culture and how you behave towards your collegues :-)

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

#188
Get the most important things right first.

Make sure the full project is split into some reasonable modules with well-defined dependencies. The internal quality of a given module is less important as long at what it does and what it depends on is clear.

It can be easier and more powerful to throw out / replace than refactor / rewrite. Modularization is what enables this.

Make sure that version control is properly used (everything including configuration is under vcs, what is in production can be easily produced, commits are done in small meaningful units), builds are reproducable. These things are more important than detailed unit testing, documentation and test coverage.

Lastly. Get used to it. Most larger projects have tons of bad code.

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

#189
post #142

Earlier quoted context omitted.

I manage my team. When I discuss projects with my manager and the senior engineering leadership, they will almost always refer to staff as resources, e.g. "team X needs a SOA resource", "team Y needs extra QA resources" and so on. It's distasteful to me; I always refer to my team and other engineers as engineers or by name, not as "resources."

To balance things out, try casually slipping in the word "overhead" when talking about management.

Wow..Why is it that I have heared the word resources used for engineers a lot of times in my life but never overhead for managers?

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

#190

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 wil…

One way to deal with it is to understand why the mess in the first place. You may find reasons to forgive the mess. If you're looking at a startup that had to try a lot of things perhaps (and when the team was junior) hitting on the workable idea later, maybe they just did what they had to do. The forgivance may also give you the incentive to improve it. A good measure is whether the shitty code does something worthwhile and interesting. Might get you to a point of empathy.

Edit: "you" = OP

Post reply on HN