Live data from Hacker News

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

news.ycombinator.com

11–20 of 25 posts

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

#11

I've worked with a million lines of C++ code written by a guy who doesn't understand C++. There's a 10k line loop that's "Unabstractable" according to my former boss. Everything stored custom linked lists, even trianglated meshes. Copy and pasted code everywhere. Maybe I should leave the organization.

Huh. I, also, have worked with a large C++ codebase written by a team of people who were not C++ programmers. Also (?) VFX code. My favourite was the 3k line long single method.

As for whether or not you should leave, that depends on how happy you are swapping your life for money. There are good jobs, but no guarantees you'll get one of them.

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

#12

I've worked with a million lines of C++ code written by a guy who doesn't understand C++. There's a 10k line loop that's "Unabstractable" according to my former boss. Everything stored custom linked lists, even trianglated meshes. Copy and pasted code everywhere. Maybe I should leave the organization.

10k line loop that's "Unabstractable"? Never ever dare to change that! It might tilt the Earth off its axis and we'll all freeze to death!

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

#13
post #7

Refactored and rewrote a >100k LOC expert system in the medical field. This was a single Java source file with one long if else tree. Everything was hard coded constants. It was like "if (setting.equals(foobar)) { if (a == 1 && b == 10 && ...) { sendAlert(); } }" There was no testing and no documentation of the feature sets involved. Rewrote the code in under 10k LOC, huge cost and performance improvements were had,…

[deleted]

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

#14
FTP. A Cisco switch was dropping a bit (or two) and managed to shuttled the packet across despite that double bit-loss in its data payload.

Had to swap FTP out with rsync.

Of course, that entailed numerous hours of master network engineer skills of tracking down data loss across several hops.

Weird how we trust the hardware buffer to keep the data intact prior to its packet hardware checksumming.

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

#15
Plenty of examples, mostly boils down to:

- some manager picks the cheapest contractor

- said contractor ships enough code to tick the check-boxes on the contract

- people who will actually use the project will not get their hands on it until its too late

- project is fundamentally broken

- management: * surprised Pikachu meme *

- management: you will need to fix this ASAP and throwing blame around is childish, so don't bother

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

#16
3 legacy rails 2 / ruby 1.8 apps, with a couple custom gems. Every single thing in the apps is so over engineered.

Meta programming everywhere, debugging what you expect to be a basic bug ends up taking hours.

They even managed to rewrite a bunch of the active record code so that the models talk to an API our big app instead of the DB. As there’s no good reason why, all it does is confuse you every time you look at it. And even when you figure out what they’ve done, you waste even more time staring blankly and asking “why…”

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

#17
>1m loc web “framework” with no documentation, no version control, no package management, no automated tests, functions several thousands of lines long, a different database schema for every deployed instance (>50), bundled binaries >10 years old...

Fucking awesome, loved every second of it. You won’t learn this stuff in school.

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

#18
Compiler class in college 20 years ago - my professors code was horrible. Var1, var2, etc… random formatting and misleading names… I learned it’s not what the variable name says or how it’s formatted- but rather what it means… to this day I believe that class is why I believe the most beautiful code is the code that works.

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

#19
A python code base where the way it was built is that the function names contained metadata about how it executed.

for example, a function name called:

  extract_metadata
or

  run_procedure

would be evaluated, the system would go through the python APIs and get the name of the function and eval each part splitting on the `_` against a set of meta-functions.

The system was big, 10s of modules, 100k`s of LoC, many many many functions. Nobody understood it or how to make a change to it. Simply renaming a function meant that the execution path in the program was different (since function names were part of the API at runtime !).

Since the output of this system was predictable (a JSON file) based in the input (~30 parameters), I ended up running integration tests of expected JSON output vs input in the system and then I rewrote the system having the integration tests passing!

The final system I built is still in the company which I left ~4 years ago used by thousands of people! Certainly proud of fixing that mess.

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

#20
i saw this happening at a demoparty, the person sitting next to me:

hekps out a friend with some coding problems; discovers a file containing a class called "superHoegen" with the function members "SuperHoegen1" ..."SuperHoegen12" took a while to realize that this was the martix class of the renderer and sth like ".SuperHoegen5()" would invert the matrix.

also there where no bugs in the superhoegen class, just funny naming :)

Post reply on HN