Inheriting a shitty code base

In a totally not surprising turn of events I have had another giant steaming pile of elephant shit dumped on my desk.

I don't want to get into the details about the whole thing, but I inherited a code base that is awwwwwwwwwweful!!!! I have to refactor it. And not because "oh I could write this better" or "this doesn't follow the standard I was taught in my university class." It's "Cotton you have to fix this code base - it no longer works correctly."

Keep in mind this is coming from a guy who maintains THOUSANDS of lines of uncommented PERL. When I say aweful - what I just got takes the ticket.

So I've ID'd why it doesn't work. But I'm afraid changing It is going to have unintended consequences because I'm a sysadmin - not one of the programmers that's been on staff for 10 years.

So, I'm Seeking advice / strategies on inheriting a crap code base of a medium high (closer to high) mission critical infrastructure process which needs quick turn around.

Fortunately I can program, but looking for high level approach to disecting bad code base.

For example print code out -> make comments everywhere -> fully understand shit code -> refactor. I don't know how to ask this properly ... uh for example, as a medic we did ABC for unresponsive people "airway, breathing, circulation" just guidelines.

1 Like

Setup a test system for testing changes to code

Map out data flow of the program. This includes anything like jumps, data stores, etc.

Recode and/or comment exsisting code.


Doing stuff like this will take you weeks or maybe even months and i wish you good luck

6 Likes

Thanks! I think right now I'm probably in the pissed off stage in the stage of acceptance. I'll get it done, but when this guy was looking at me telling me this - I was like freal?!?!? And on a Friday at 5:15?!?

Sometimes I'm jealous of our programming team. When they get hit with stuff like this they pull together -it's really cool to see. However, being a lone sysadmin can get hairy...

If they are expecting you too get this done in like a day or two then you need to tell them to find someone else

4 Likes

You know what they say, patch one bug - put 12 new ones into production - lol!

2 Likes

The good news is the part I'm going to fix is at least a terminal branch of the overall "trunk" but its the business end of a major enterprise-wide process.

Thanks for the support.

First of all, make sure your using some form of version control (I favor git).
Keep your commits small - each commit should only change one thing (and comment your commits properly, see https://chris.beams.io/posts/git-commit/)
Build a test suite that covers current functionality before changing anything. This should be a separate project/program to the current code - try to leave the codebase untouched initially.
Then start refactoring - your test suite will ensure you're not breaking things as you go and the version control will provide the history of the changes if something does go odd.

5 Likes

Just wanted to update. I completed this.

Found out today I'm going to be embedded with the programming team for further process improvement.

5 Likes

Any enlightenment on how you handled the process or any oh shit moments?

I would REALLY enjoy any information on this. As a hobbyist, it is very enjoyable to see how the big kids play.

Honestly, @sanfordvdev I'm so disillusion by this whole thing that I don't have the energy to describe what happened right now. I wanted to update everyone here that I'm okay and wholly conquered that shit.

It was not easy. They dumped a gigantic mess on me and left me out to clean it up, alone. I'm wondering where the hell my team was?

I'll explain how I approached it later, but right now I'm still a little no happy about the situation.

Copy no problem I can understand that. Holler back at us when your mind is cleared after some time and drinks.

I'm just going to leave this here:

I'd love a write-up though :)

6 Likes

i comment the hell out of everything i learn about in the codebase.

I plead guilty to committing a felonious necro here, but…

After being embedded with the programmers for a year, I’ve been pulled. Our systems engineer left the organization and now I have his desk…

Uhh… yay - I guess…

2 Likes

well has the bad code base been fixed or is it still a flaming pile of poo. and good luck with your new desk.

I demand to know more. Hearing about progress and how you made it would be a value add.

I am sure if this was a catastrophic issue the mods would lock every thread older than a year.

Hope the engineer leaving is not a bad sign. It can be if they leave in droves!

“Always leave the job a little better for the next guy.”

Old firefighter quote

I live by it and who ever inherited that branch has a it better than I found it, plus the other areas I covered.

4 Likes