Ask HN: Worst code you ever had to fix up?
21–25 of 25 posts
Re: Ask HN: Worst code you ever had to fix up?
#22Re: Ask HN: Worst code you ever had to fix up?
#23I 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…
Re: Ask HN: Worst code you ever had to fix up?
#24Re: Ask HN: Worst code you ever had to fix up?
#25It 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.