Live data from Hacker News

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

news.ycombinator.com

291–300 of 346 posts

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

#291

Earlier quoted context omitted.

The first course of action if you find some ugly/bad code is to ask a dev with more history with the codebase why it's like that. In my experience 9 times out of 10 the answer is "we know, it's like that because of reason but we haven't had the time to fix it yet".

Surely in a commercial setting the primary factor is RoI rather than time? Will rewriting this old, stable, code increase profits or substantial reduce revenue impacting risks? #notacoder

Often, it's a simple case of business need. As long as the offices are clean, the business doesn't really care if the cleaning cupboard is tidy.

It applies to a lot of business areas. If you want to introduce new processes or fix any problems, you need to justify why you want to do that, and "This isn't very pretty" isn't generally considered a good enough reason. If something works, nobody ever got into trouble for leaving it alone.

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

#292

Earlier quoted context omitted.

The first course of action if you find some ugly/bad code is to ask a dev with more history with the codebase why it's like that. In my experience 9 times out of 10 the answer is "we know, it's like that because of reason but we haven't had the time to fix it yet".

Surely in a commercial setting the primary factor is RoI rather than time? Will rewriting this old, stable, code increase profits or substantial reduce revenue impacting risks? #notacoder

> Surely in a commercial setting the primary factor is RoI rather than time

If it's a smaller company (op mentioned 50-100 people) they might not even know what RoI is, and/or might not care about it.

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

#293

Earlier quoted context omitted.

The first course of action if you find some ugly/bad code is to ask a dev with more history with the codebase why it's like that. In my experience 9 times out of 10 the answer is "we know, it's like that because of reason but we haven't had the time to fix it yet".

Surely in a commercial setting the primary factor is RoI rather than time? Will rewriting this old, stable, code increase profits or substantial reduce revenue impacting risks? #notacoder

Same thing. The time is the investment. There are always projects with better RoI so a rewrite is constantly at the bottom of the pile. "We'll get to it someday."

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

#294

This sounds normal. Back in the 90's and early 2000's, almost nothing had automated tests. Miraculously, things still got done by manually testing. On the other hand, I worked at shops where every getter and setter had a test. Not much got done there.

> Miraculously, things still got done by manually testing. That is still very normal and not very miraculously considering it happens all the time and very large companies run on this practice. Although I am a fan of automated tests, I work with enough codebases that are robust and have been working for over 10 years that have no tests and others with a lot of test that are still fragile and miserable to work with. I…

Yes, I was being sarcastic with the "miraculous" comment. The right answer is definitely a middle ground...

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

#295
Been there, done that. Here's the TLDR approach:

Perform small, incremental refactoring.

Spend 2/3rds of your time adding / updating tests.

(If you can,) involve the original author in code reviews.

Figure out what the original author did right. If the project appears to work, something was done right. Make sure to maintain the right design patterns, libraries, frameworks, testing tools, ect, as long as you can.

Honestly, refactoring is my favorite part of programming. Taking something that "almost" works and turning it into something that's industrial strength and maintainable is what gives me the most professional joy.

(Edit) The last time I was in this situation, the product had very visible problems. I had to put my foot down and declare that they had to be fixed, because no one would use our product if they weren't fixed. If you can point to a problem, like hard scalability limits that management agrees will become an obstacle to company growth, that's your way to get buy-in for refactoring.

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

#297
post #210

Earlier quoted context omitted.

> SOme people are really precious about their shitty code and can't take criticism, esepcially in small companies. It's very easy to criticize, often not easy to understand the situation where the bad code was written. Maybe the hastily-written code was the thing that saved a company from bankruptcy and was written by dedicated engineers, and bringing your friend to fix it was the plan all along, and what they needed…

> It's very easy to criticize, often not easy to understand the situation where the bad code was written. A lot of people seem to think that criticism of the code is the same as criticism of the person who wrote the code. They are not the same thing. Root knows I've written plenty of crappy code over the years for very valid reasons. You are not your code, saying the code sucks doesn't mean I think you suck.

[deleted]

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

#298
post #100
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?

Unfortunately, yes. We are just replaceable cogs.

I'd rather be a replacable cog than a crucial lynchpin. I prefer to look at my job in the same way. It's much less stressful that way.

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

#299

Earlier quoted context omitted.

These people should have asked to see a sample of what they were going to have to work on.

They didn’t even have a look at the code. Their task would have been to write and maintain end-user documentation and they left before they even had computer and stuff set up. Just never came back from lunch. Said they’d not feel up to the task. I was just a student at that time, so I can’t really say if that was a hiring fuckup or just an odd person. Certainly one of the weirder things to witness in my career.

[deleted]

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

#300
post #210

Earlier quoted context omitted.

> SOme people are really precious about their shitty code and can't take criticism, esepcially in small companies. It's very easy to criticize, often not easy to understand the situation where the bad code was written. Maybe the hastily-written code was the thing that saved a company from bankruptcy and was written by dedicated engineers, and bringing your friend to fix it was the plan all along, and what they needed…

> It's very easy to criticize, often not easy to understand the situation where the bad code was written. A lot of people seem to think that criticism of the code is the same as criticism of the person who wrote the code. They are not the same thing. Root knows I've written plenty of crappy code over the years for very valid reasons. You are not your code, saying the code sucks doesn't mean I think you suck.

> You are not your code, saying the code sucks doesn't mean I think you suck.

Some people take _any_ criticism of their code personally regardless of how constructive you are being.

I have had a person completely blow up at me for simply asking (literally a question - a valid question) "why did you choose to use a BindingList instead of a List?"

Maybe it was how I phrased it? People are tough to get sometimes.

Post reply on HN