Earlier quoted context omitted.
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.
> Tests that run for 30 hours is an indication that nobody bothered writing unittests. Yes, they were not unit tests. There was no culture of unit tests in the Oracle Database development team. A few people called it "unit tests" but they either said it loosely or they were mistaken. Unit test would not have been effective because every area of the code was deeply entangled with everything else. They did have the con…
Ask HN: What's the largest amount of bad code you have ever seen work?
371–380 of 601 posts
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#372I had never written in LISP before, so I bought a book!
I was having trouble reading the program on the computer, so I printed out the roughly 15,000 lines. Not a lot, I know, but it was about an inch and a half thick stack of paper. I started going through it.
It consisted of LOTS of subroutines. Thousands. Each one neatly formed; no more than a couple hundred lines. It gave me hope.
It read in the text file, created a blob of a string, and then passed that blob to the first subroutine. Then it passed to the next subroutine. And then the next, and so on. As far as I could tell, it never called a subroutine a second time, and it never returned to the starting method. Given the strangeness of LISP, I couldn't figure out what it was doing, or why.
The guy who wrote it had retired, and we didn't get along anyway, so I didn't try to chase down what his thinking was.
I gave up.
To my knowledge, they're still using that program 17 years later.
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#373Earlier quoted context omitted.
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.
Always test "outside-in", i.e. integration tests first, then if you can afford it, unit tests. Integration tests test those things you're going to get paid for... features & use-cases. Having a huge library of unit tests freezes your design and hampers your ability to modify in the future.
I post this all the time, it's like free upvotes :)
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#374We have absolutely no idea how to write code. I always wonder if it's like this for other branches of engineering too? I wonder if engineers who designed my elevator or airplane had "ok it's very surprising that it's working, let's not touch this" moments. Or chemical engineers synthesize medicines in way nobody but a rockstar guru understands but everyone changes all the time. I wonder if my cellphone is made by mac…
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#375Ten years ago I was called in to remediate a new web application which had been subcontracted to an Indian development company. The PHP developers who'd put it together evidently didn't know about classes, and each page in the application was hundreds, sometimes thousands, of lines of spaghetti code, most containing the same duplicated (but subtly changed) blocks providing database connectivity etc. Security had not…
10 years ago PHP didn't have classes
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#376Earlier quoted context omitted.
What sorts of techniques did they use? I'm very curious to see/hear examples.
function isTrue(v) { var result; result = v; if (!isFalse(result == true)) { return result; } else { return isFalse(result); } } function isFalse(v) { var result; result = v; if (!isTrue(result == true)) { return isFalse(result); // Tail recursion so this is fine. } else { return result; } } if (isTrue(myBool) == true) { // TODO: Could this be refactored to isTrue(isTrue(myBool))? return true; } else if (isTrue(isFal…
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#377I 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…
Was there a reason they did not use DBI to call the code ?
The java mess was a pattern copied from within the company where it was used correctly. The main product of the company was built around some very complex scheduling software. It was a black box and communication was entirely through inter-server beans. This was copied to intra-server, which makes no sense at all, and it was used everywhere.
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#378At an old employer there were 15,000 lines of batch script across 14 .bat files on a Windows laptop. Old director of IT used it to onboard new customers. It basically copied a DB and turned "CHANGE ME" in some columns to the client's name.
It had it all. 5k lines of date validation, 3k lines of "UI", 400 goto statements, hard-coded passwords, versioning by incrementing the file names (leading to a bunch of code that was never called), and to top it off a static IP granted to the laptop that used as a part of authentication.
Took me two weeks to unravel it and replace with ~20 lines of Ruby.
Later, all of my complaining on Facebook led an old professor to invite me back to give a talk on the importance of code quality!
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#379[deleted]
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#380Earlier quoted context omitted.
Love the idea of this. In my experience it's far easier to introduce testing by focusing on unit testing complicated, stateless business logic. The setup is less complex, the feedback cycle is quick, and the value is apparent ("oh gosh, now I understand all these edge cases and can change this complicated code with more confidence"). I think it also leads to better code at the class/module/function level. In my exper…
In general, I test those things that relate to the application, not those about the implementation. i.e. Test business logic edge-cases, don't test a linked-list implementation... that's just locking your design in.