Live data from Hacker News

Ask HN: Worst code you ever had to fix up?

news.ycombinator.com

21–25 of 25 posts

Re: Ask HN: Worst code you ever had to fix up?

#21
company with an in-house compiler of a functional language, w/ no chanche to have a breakpoint or know whats what in the disassembly, generates ~800 lines of assembly for the simpelest things. turns out that someone did not read the specs and used xorps in a funny, heisenberg-ish way.

Re: Ask HN: Worst code you ever had to fix up?

#23

I work for a US-based company that has been trying to expand overseas for a decade or so by acquiring smaller companies overseas. When we expanded into South America we bought a Brazilian company. I guess it didn't work out because within 2 years the company decided to shut down the Brazilian office and (unfortunately) all of the Brazilian-based developers were let go. The website was handed over to us, and we were t…

You tried saving it, and at the end you did :)

Re: Ask HN: Worst code you ever had to fix up?

#24
I once refactored a 15K line single function written in Matlab with no tests, source control, comments, docs, etc. Someone had very helpfully nested the entire function in a try catch block which displayed "the program experienced an error" in lieu of any exception being thrown because "they were told to handle exceptions"

Re: Ask HN: Worst code you ever had to fix up?

#25
My favorite was the classified Airfields database for the US military. It used to be called AFIS, I think. If there was a commercial or military airport, road, or strip of grass anywhere in the world that had supported or was believed to be able to support landing an aircraft, it was supposed to be in this database. This was on the ancient WWMCCS classified Honeywell mainframe system.

It was … I don’t know how many … lines of COBOL-66, and part of the job we had in late 1989 was to bring it into the modern future of COBOL-77. My TOP SECRET/SCI clearance wasn’t complete yet, so I got tasked with helping to rewrite this CONFIDENTIAL bugger.

Turned out that the only thing classified about it was the code that handled the great circle calculations for determining distance from one airfield to another. I recall that one of the first things we did was to move that one routine to a separate printout, so that would have to stay locked up in the safe unless we were doing something with it, but all the rest of the code was unclassified and could be kept on our desks.

After that, about halfway through the conversion, it dawned on me that the code in this system was split into two parts — one huge monster routine that literally did everything that the code could do, and another copy where you could pick and choose what things you wanted. It occurred to me that we could cut out half of the code of the system by using just one set of routines for both functions, and if someone wanted to run a “kitchen sink” report, then we could just fill in the fields behind the scenes as if they had actually manually selected every option that was possible. No one would ever know the difference, and we wouldn’t have to maintain two copies of every single routine.

That one change cut the code base down by about 40% in size. Thousands and thousands of lines of code, at least.

We did later discover that there had been some minor cosmetic tweaks put into the system, so that if you had the code set up to generate properly formatted output on the READINESS system, when you took that exact same code and ran it on the production NMCC system it would then result in an extra blank page being printed between every page with text on it. But if you set it up to properly format on the production NMCC system, it would be a line short on the READINESS system and output would slowly get out of kilter and wouldn’t match up with the natural page-breaks of the fan-fold paper.

The older version of the code ran perfectly on both sides. There was something buried deep in the old code that we were never able to figure out what was going on so that we could properly replicate it.

So, yeah — I don’t officially admit to having ever programmed in COBOL, but I did. And this is probably one of the best programming achievements I ever had in my life as a person who does not write code.

Post reply on HN