Live data from Hacker News

You've just inherited a legacy C++ codebase, now what?

gaultier.github.io

271–280 of 356 posts

Re: You've just inherited a legacy C++ codebase, now what?

#271

Earlier quoted context omitted.

Question: Why does some of the product source code look like it is the output of a decompiler? Answer: Our office was in the WTC and was destroyed on 9/11. Luckily everyone got out alive, but then we discovered we had no off-site backups of the source code. In order to continue development, we had to retrieve the released binaries from our customers and decompile them to get back source code.

Oh.. Ouch, ouch, ouch. I feel for you. That must have been hell.

I wasn’t there for 9/11, my involvement with that code base started a few years later. But it was clear it was a traumatic memory for colleagues who had been

Re: You've just inherited a legacy C++ codebase, now what?

#272
post #252

Earlier quoted context omitted.

Question: Why does some of the product source code look like it is the output of a decompiler? Answer: Our office was in the WTC and was destroyed on 9/11. Luckily everyone got out alive, but then we discovered we had no off-site backups of the source code. In order to continue development, we had to retrieve the released binaries from our customers and decompile them to get back source code.

I see this as a case of: "see, allowing wfh would have saved you there."

From what I was told, WFH and people starting late actually really helped, in that there were only a handful of people physically in the office when it happened. But apparently the server with the source code on it was in it too. I don’t know if they forgot about off-site backups entirely, or if they thought they had them but only discovered they were incomplete or faulty afterwards

I don't know what the practice was at that time, but some years later, people weren't allowed to have the source on their laptops, they had to SSH/RDP/etc in to a hosted development system to work on it, which might explain how losing the office resulted in losing the source code even with people doing WFH

Re: You've just inherited a legacy C++ codebase, now what?

#274
post #229

Earlier quoted context omitted.

That's a feature! New warnings added to new compiler versions can identify problems that weren't previously detected. You _want_ those to -Werror when they happen, so you can fix them if they need it. Changing a compiler version is a task that has to be resourced appropriately. Part of that is dealing with any fallout like this. Randomly updating your compiler is just asking for trouble.

It is certainly not a feature because it make all infrastructure including just regular old checkout-and-build workflows break for historical versions of the code. It’s so annoying to have to checkout an older version and then have to go disable -Wall -Werror everywhere just to get the damn thing to build. Keep master clean of any warnings, for sure. But don’t put it straight into the build system defaults.

Just updating a compiler could break workflows for historical versions of the code. It is unavoidable. But it is easier with build flags if you use VCS: these flags could be different for different versions.

Re: You've just inherited a legacy C++ codebase, now what?

#275
post #125

Earlier quoted context omitted.

The scripted, packaged docker with toolchain dependencies and _is_ the build. If someone decides to use a different toolchain, the problems are on them.

Yeah that works if you are not dealing with open source. If you are dealing with open source, though, it really won't save you that much trouble, if anything it will just lead to unnecessarily hostile interactions. You're not really obligated to fix any specific issues that people report, but shrugging and saying "Your problem." is just non-productive and harms valuable downstreams like Linux distributions. Especiall…

I would say it's still worth having -Werror for some "official" CI build even if it is disabled by default.

Re: You've just inherited a legacy C++ codebase, now what?

#276

Earlier quoted context omitted.

Everyone who has been around this game for long enough has scars. At one point in the early 90s I was asked to take over maintenance of a vertical market accounting app that had a few hundred users. It had been written using Lattice C, but at the time was being built with the ultra modern MS C 5.1. The first time I looked at it, I saw that the make file set the warning level to 0 and redirected the output to NUL. Rem…

Was there a warning for implicit function declaration and implicit variable type for each variable and call that used those? Or how could there be that many warnings.

Yes, plus a bunch of warnings for unsafe type conversions where the compiler did pointer to int, back to pointer conversions. In the process of cleaning it up I found at least a dozen serious bugs.

Re: You've just inherited a legacy C++ codebase, now what?

#278
If you have a codebase with lots and lots of tests, you are not in a bad place. Remember legacy means a codebase that works and solved and still solves problems over decades. In a sense,a successfull software project implies it will be marked as legacy. Always prefer legacy over Hype.

Re: You've just inherited a legacy C++ codebase, now what?

#279

It's funny. My first step would be 0. You reach out to the previous maintainers, visit them, buy them tea/beer and chat (eventually) about the codebase. Learned Wizards will teach you much. But I didn't see that anywhere. I think the rest of the suggestions (like get it running across platform, get tests passing) are useful stress tests likely to lead you to robustness and understanding however. But I'd def be going…

I was once tasked with deploying a piece of software on a closed network (military), to run on a old custom OS - it wasn't a huge program, around 50k lines of code.

I did encounter a bunch of bugs and problems underway, and wanted to reach out to the devs that wrote it - as it was customer made for my employer.

Welp, turns out it was written by one guy/contractor, and that he had passed away a couple of years earlier.

At least in the defense industry you'll find these sort of things all the time. Lots of custom/one-off stuff, made for very specific systems. Especially on the hardware side it is not uncommon that the engineers that made the equipment are either long gone or retired.

Re: You've just inherited a legacy C++ codebase, now what?

#280

Not mentioned were code comprehension tools / techniques: I used to use a tool called Source Navigator (written in Tcl/tk!) that was great at indexing code bases. You could then check the Call Hierarchy of the current method, for example, then use that to make UML Sequence Diagrams. A similar one called Source Insight shown below [1]. And oh, notes. Writing as if you're teaching someone is key. Over the years, I got…

> I used to use a tool called Source Navigator

I can't believe I'm finding someone in the wild that also has used Source Navigator.

My university forced this artifact on me in the computer architecture course because it has some arcane feature set + support for an ARM emulator that isn't found elsewhere. We used it for bare metal ARM assembly programming

Post reply on HN