Live data from Hacker News

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

news.ycombinator.com

211–220 of 346 posts

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

#211

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…

I agree here, but keep copious notes. I've found mind mapping software, like freemind is good for this. It will help keep you sane. Without that, IMO trying to internalize large amounts of badly written code can negatively affect your brain's ability to come up with good, well written code. All those bad ideas and patterns become the first things that pop into your mind when you try and solve problems. “When you star…

Do you have any example of how you use mind mapping. I've tried a few times to use it but have yet to find a good way to layout my notes/thoughts in a map.

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

#212

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…

excellent advice.

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

#213

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…

To add on to this, you can still improve the code quality while building on it by adding tests as you go, so you can have some solace and also sanity when testing your own code.

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

#214
Write lots of tests first, fix the code as they break. Don't make it personal for the people who wrote it. You don't know the conditions under which they originally wrote it. All else fails, join a start up early and write a whole bunch of shitty code in an existential panic.

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

#216
Sounds familiar. I've worked on a similar code base, old code written during the startup years that is messy and have lots of subtle bugs and is a complete dependency mess.

When I joined I was told by one of the (post-startup) devs he had a rule: whenever he had to fix a bug or add a feature to a piece of code, he'd try to clean up the method or class he had to work on to implement the change. Bigger changes then allowed for bigger cleanups.

We also had the challenge of testing. So we decided to accept the situation, that we have a fragile project and that our changes will lead to bugs, and instead wrote an infrastructure that made it easy for our users to launch older versions of our application. For the most part this meant blocking bugs were not such a PITA for users, if we broke version 42 they could easily launch version 41 and use that until version 43 with a fix came along.

As for saying the lead guy did a bad job, I think you're making the mistake of looking at the code as the most important thing. It really isn't. The application and its functionality is the most important thing. Functionality is what makes the application useful to users. An application with no users is useless.

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

#217
> Should I just go and basically say that this person did a bad job?

You have no idea of the conditions and constraints this person was working under. You don't know if you would be able to do a better job given the same conditions (spec, schedule etc.). It is possible they did a bad job. It is also possible the did a very good job.

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

#218
post #111

Earlier quoted context omitted.

Rewrites are riskier when requirements need to be reverse engineered from the current solution, or if requirements are complex. When requirements are simple, rewriting should be simple. This should at least give you the opportunity to contain technical debt to the most complex requirements. To say "everything is complex therefore we cannot rewrite anything" is pretty implausible and mediocre.

I disagree. Rewrites are risky because you're changing code that has been working for some time. It is easy to introduce bugs into a sufficiently complex system when refactoring. "The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they’ve been fixed. There’s nothing wrong with it." - Joel Spolsky

I doubt Joel Spolsky was equating legacy code with technical debt in this quote. Not all technical debt is robust and well tested legacy code.

Chromium for instance has code from the original KHTML written in the 90s, most of that remaining code is reasonable and makes sense today. If it didn't someone would have replaced it.

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

#219
post #195

That thing you call “mess” is in fact bug fixes, late to arrive business logic, and tribal knowledge.

When time estimates become deadlines and the politically correct "Didn't we agree that it will be done by day X". Also, needs to be built by Wednesday and we will have the specs for you on Friday.

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

#220
post #17

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…

Yes, so good. Martin Fowler's Refactoring is an excellent companion to Feathers' book.

It will be worthwhile to know that a second edition of that book is expected to come out shortly.
Post reply on HN