Live data from Hacker News

Ask HN: What's the largest amount of bad code you have ever seen work?

news.ycombinator.com

221–230 of 601 posts

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#221
In my first year of university, I wrote a Java swing game which had classes for literally every part of the GUI (I was young, carefree and unwilling to yield on the principals of OO I'd been taught earlier in the year. I think it had somewhere in the region of 100 classes. Of which only about 3 had the real logic in them.

Now I've put it in perspective, I went on to an intern position between years 2 and 3 of uni. I was handed a lovely piece of code which had:

- Around 300 classes - 3 or 4 layers of nested generics - Factories, factory factories, generator factory factories - 90% of the parameters were passed in from the build engine running the code, so it was impossible to run locally, ever. - 0 tests - Some 100 pages of documentation, which had been lost until I was about halfway through my placement (and mostly documented how to set up and run it, not how to maintain it)

Seriously, this thing was designed to the extreme, made to be generic to every single scenario in existence.

So what did it do? It took items from a customer facing system, transferred it onto the internal work tracking system. Then when they were updated in the modern system, mirrored the relevant updates back to the legacy.

The best part? Every time the internal work tracking system updated (once every 6 months), this thing broke horribly and it was practically impossible to fix. Even if you managed to set up stuff so you could work in a development environment, it still connected to the customer facing system, so you had to be incredibly careful what you did during testing.

It wasn't the biggest in terms of LOC, but it astounded me just how much effort (apparently the guy who wrote it squirreled away for a year to write it, then moved to Canada, and was famous in the department for having one too many beers during a outing to a local Indian) went into designing this behemoth.

I still have the occasional nightmare about it!

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#222

Earlier quoted context omitted.

Sounds like a market opportunity. What vertical market is this, more specifically?

Market opportunity? Sounds more like the best way to throw away your sanity. Some things are just beyond repair.

Since when is a greenfield app on a new product addressing a market with only old entrenched players “throwing away your sanity?”

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#223
post #168

I am maintaining one application in construction industry space. That application was created 25 years ago by construction worker that never wrote single line of code before, but because he caused a lot of problems on construction site they give him Programming 101 book and let him build it. 15 years later the app was close to half milion lines long of huge bowl of spaghetti code. Only comments in whole codebase were…

what kind of problems do you cause at a construction site that do not get you fired but reassigned to Programmer with programming 101 book?

Perhaps he played too much Minecraft and tried building a Turing machine from the materials on the construction site?

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#224
The one I am currently working with - Multiple calls to the database (a lot of times in a loop) - Rather than reference, or variable passing, DB id is passed as a parameter to functions, so multiple calls to the database for a single object per API call - Database design was normalized initially, for "optimization" most of the database has been denormalized. - Queries without index - If we were to create an index, probably have to create index on every column - one of the function has more than 36 if else (including nested if else) - Does not work with database partitioned or multiple databases - OLAP like queries running wild on OLTP systems, just because we can - Fastest API call - 1 second, slowest - It started as an outsourced project and the same codebase is being dragged on, with features being added every day and with no coherent plan.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#225
post #134

Earlier quoted context omitted.

This is a complete fallacy IMO. The time is 10 fold down the line when people are attempting to reverse engineer in order to maintain it.

Presumably, down the road, you'll either be a defunct company or doing well enough to afford 10 times the manpower to fix things. Facebook was a spaghetti code mess in the beginning. I'm sure it caused them some growing pains, but moving too slowly early on would have likely been more costly.

Both you and this comment's parent are correct. Which doesn't say anything about the nature of software engineering or project management, but more the importance of taking context into account when considering advice.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#226
post #168

I am maintaining one application in construction industry space. That application was created 25 years ago by construction worker that never wrote single line of code before, but because he caused a lot of problems on construction site they give him Programming 101 book and let him build it. 15 years later the app was close to half milion lines long of huge bowl of spaghetti code. Only comments in whole codebase were…

what kind of problems do you cause at a construction site that do not get you fired but reassigned to Programmer with programming 101 book?

From my experience this means they had a strong union.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#227
post #27

Earlier quoted context omitted.

At least there are tests!

Tests that run for 30 hours is an indication that nobody bothered writing unittests. If you need to run all tests after changing X, it means X is NOT tested. Instead you need to rely on integrations tests catching Xs behavior.

Integration tests are pretty important in huge codebases with complex interactions. Unit tests are of course useful to shorten the dev cycle, but you need to design your software to be amenable to unit testing. Bolting them onto a legacy codebase can be really hard.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#228
post #18

Oracle Database 12.2. It is close to 25 million lines of C code. What an unimaginable horror! You can't change a single line of code in the product without breaking 1000s of existing tests. Generations of programmers have worked on that code under difficult deadlines and filled the code with all kinds of crap. Very complex pieces of logic, memory management, context switching, etc. are all held together with thousand…

That is absolutely insane. I can't even begin to imagine the complexity of that codebase. I thought my Rails test suite was slow because it takes 4 minutes. If I wrote it in C or C++ it would probably be 10 seconds.

I can't imagine a C/C++ application where the test suite takes 20-30 hours on a test farm with 100-200 servers. And if you can break 100-1000 tests with a single change, it doesn't like things are very modular and isolated.

And 30 hours between test runs! I would definitely not take that job. That sounds like hell.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#229
post #176

The worst program I ever worked on was something I was asked to maintain once. It consisted of two parts. The first was a web application writen in ASP. The second portion was essentially Microsoft Reporting Services implemented in 80,000 lines of VB.NET. The first thing I did was chuck it into VS2010 and run some code metrics on it. The results were, 10 or so Methods had 2000+ lines of code. The maintainability inde…

[deleted]

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#230
post #187

I took over a Perl project where every SQL call was an exec to a java program which would make the query. The largest madness was a J2EE mess where persistence was achieved by taking your current object, sending a message bean to the server, it would touch the database and return the result which was being polled for (making it synchronous). The amazing thing is that the client and the server were the same J2EE insta…

Reading this gave me a thought, which is that I would like to see a series of artistic renderings of physical analogies for such sorts of Rube-Goldberg-Machine-esque software monstrosities. This one sounds like it'd be an assembly line where in each step of the process, the piece-in-progress would be packaged in a shipping box and sent through the mail C/O the person manning the next station 15 feet away.
Post reply on HN