Live data from Hacker News

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

news.ycombinator.com

191–200 of 346 posts

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

#191

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 came to this also. In first months of work is learning process: practices, workflows and processes. Then you should introduce changes via retrospectives. The same solution for outsource companies, that joined to old project. There are no time for such thing as debates which eggs are better. It should be introduce smoothly.

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

#192
This is why I'm most interested in two things when interviewing for a job. 1) Are the devs happy/How long have they been here 2) can I see code?

I have been there and the sad truth is that for most codebases I'm going to argue that bringing the whole thing up to a nice status is going to cost too much if it's already in production. Unless it's going to be running for many many years, it's probably not worth the investment. And if it's not worth the investment, then there will be no investment. That may be the correct management decision - but it's a huge red flag when choosing a workplace.

If the code isn't in production already, then it's another matter. Then you can make it worse before it gets better, and it may be a productivity boost even if the cleanup takes several years.

The thing to look out for if you can't clean up the whole thing, is any kind of modularization. Can you suggest that some subsystem is either rewritten or refactored? Make a business case such as "we have so many bug reports in subsystem X" or "We could easily make Y processing 10x faster". Even without tests, it's sometimes possible to implement a new subsystem and use a previous subsystem as the test - your new subsystem works if it responds the same as the old one.

If you are not allowed to take an architectural or greenfield approach (i.e. you can neither rewrite or do large-scale refactorings of at least parts of the code) and you are simply asked to provide small focused (business-driven) changes to the code, and management shows no clear dedication to large scale refactoring or rewriting, then I'd reconsider working there.

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

#193
I am actually in the exact same position, in fact if the person in charge of the code base i am working on checks this thread will most likely think i am the author, and that would get me into trouble, that's how similar our situations are xD.

The only difference in my case is that i have to add more functionality to the project, i started by trying to refactor and clean the code, after a while i realized that this is almost impossible and has no visible benefits from the higher managers's point of view. So i adapted my self to write spaghetti code like the one i am facing, just to meet the deadline, and i am planning to get the hell out from here next week (resign).

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

#196
post #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 use…

Sadly, if the code could be split into modules without very high risk or massive work - then it's already in pretty good shape. The most obvious sign that a codebase is bad is that it cannot be modularized at even a few points without breaking compleytely, and doesn't have the test suite to guide that process.

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

#197
post #3

Are you working at my company? Ok, more seriously: that’s the way existing code is about 90% of the time - it’s the reality of working in our field. It may or may not reflect on the original developer. Maybe they were learning a new framework. Maybe they were rushed. Maybe it was originally intended as a prototype but ended up in production. Maybe the requirements have grown or changed significantly since it was impl…

> Then give them a few options with trade-offs. I had (well, I’m in the middle of it, so have ) to fix a few bugs in a project that are the by-products of a deeply flawed architecture. I came to my boss and explained a handful of ways that I could potentially solve the problems, and made it really clear that the best way to go would be to completely redo this one part. He agreed with me, though he wasn’t happy about…

> Hopefully your managers will appreciate you giving them options.

Take this one stage further, taking solutions to your manager is worth 10x taking problems to this manager.

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

#199

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 stare into the void, the void stares back into you” sort of thing...

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

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

> functionally correct.

It is often true that someone with very strong domain knowledge may have had this project in their head for a long time, and one day, all-of-a-sudden, has to code it all in a rush. I have had this, where external factors shifted the companies priorities.

In this case you can 'brain dump' a lot of code very quickly, get it functionally correct and make intelligent judgement calls about the threats of edge cases... especially if it is internal company software.

However, coming at the problem from cold, without the benefit of this knowledge requires significant analysis and engineering effort to get equivalent results. So tread very carefully.

But yes, add tests

Post reply on HN