DEV Community

Bobo Brussels
Bobo Brussels

Posted on

Who has written the worst code? Can anyone top this?

From this thread...

I once worked on a SQL query that took seven days to execute. Exact same situation.

I recommend folks go into the original thread and see if they can outdo that. 🤣

Top comments (7)

jrothlander profile image
jrothlander • Edited

I've been writing code for 30-years. I have my top 5.

  1. 5,000 line IF structure that was copied 5 times with a few simple changes in each of the 5. Apparently, they didn't know how to create a function or invert the IF. This was written by a very well known consulting company and we paid a LOT of money for it.

  2. An integration app that took 7-hours to run. I rewrote it, doubled the volume, and it ran in less than 15-minutes... really. Same company and developer from #1 above wrote it as well.

  3. I once ran into a function that was basically... if key == "A" return 1, elseif key == "B" return 2, elseif key == "C" return 3. Then they did all of the uppercase characters and numbers. It took me awhile to figure out they were capturing the keyboard and converting it to a number. I replaced those hundreds of lines of code with something like return (int)key -65;.

  4. I was hired by an insurance company to come in for 2-weeks and do a project to read an Excel file into a db for another app to use an input. It took me a couple of days to figure out what they were doing and that every year, they hired a consultant to come in for two weeks and tweak the code. The problem was that they hardcoded the column names they were reading, so it had to be tweaked every year. If I recall, they had been doing this for like 10-years. So the first day I figured out how it worked and the second day I rewrote it to make it dynamic and search for the columns it needed before processing them. So after day two I had it working and explained that next year and going forward, they would not need to tweak it. So I packed up and went home after the 3rd day. I guess I could have milked another week and half, but I didn't want to take advantage of them, as it was obvious that the previous contractor had been milking them for years.

  5. And here's one of my own. When I was 18 I got my first programming job writting LISP. I had skipped over trig in highschool because my guidance counsler told me I had to start with College Algebra anyway. She was a... well, she was something. So having not been exposed to trig, I ran into a function that needed cosign and I didn't know what that was. So I wrote my own cosign function.

It was about 300 lines of code. My boss, who was an engineer with about 30 years experiance, looked at it and asked me what on earth I was doing. So I explained to him that I had this point and need to plot an arc with this radius, but I didn't know where it ended. So I figured out that for every x rise, it ran x distance and I computed a constant and used the radius of the arc to determine where it would end. He thought it was funny and sat down and explained cosign and we replaced my 300 lines of code with 1 line of code. But still, I got to create my own cosign function without knowing what it was. How many developers can say that? Yeah, I know... no one should ever have to say that. But I still think that is pretty cool. I really wish I had kept the code... but unfortuneatly I did not. I guess you really do need to know trig after all.

jrothlander profile image

I think it was early versions of Amazon that submitted your userid and password unencrypted over the web. So you could snif traffic on your machine and see what was coming through, and see your user id and password show up... as well as anyone else's that happened to come through your machine.

It was pretty fun back then, back when even cell phones and wireless phones were not using encryption. So you could listen in to all of the calls in your neighborhood using a $200 scanner from RadioShack... if you knew which resistors to remove to open up those frequencies.

alaindet profile image
Alain D'Ettorre

I worked for a very short time in a company where there were 800-lines-long SQL queries that took minutes to execute and tables with megabytes-long comma-separated string fields of IDs "simulating" joins that had to be refreshed on every new insertion in the table. Most of the times, "refreshing the table" failed due to timeouts

brunoj profile image

Challenge accepted

Some comments may only be visible to logged-in visitors. Sign in to view all comments.