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

Bobo Brussels @booboboston

Joined:
Jan 7, 2022

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

Publish Date: Apr 7 '22
13 7

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. 🤣

Comments 7 total

  • Bruno
    BrunoApr 7, 2022

    Challenge accepted

  • jrothlander
    jrothlanderApr 7, 2022

    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
    jrothlanderApr 7, 2022

    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.

  • Alain D'Ettorre
    Alain D'EttorreApr 8, 2022

    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

  • Jakub T. Jankiewicz
    Jakub T. JankiewiczApr 8, 2022

    I've seen code written in PHP, probably by some indian guys, If I remeber the person need to pay $2k for that shit. It was the worse code I've ever seen. If I remember it had code like this:

    $arr = array(1,2,3,4,5,7,8,9,10);
    $output = array();
    foreach($arr as $i) {
       $output[] = "something_" . $i;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    and a lot of stuff like this. I think they didn't know about for (;;) loop. I whish I didn't deleted that code.

    Long ago there was website with WTF code, I've added this to the list, but I don't rember what site it was.

    The code had also multiple jQuery included on the page just to use single plugin.

    But the best thing was MegaMenu jQuery code, that was kind of obfuscated so no one know what it was and was not able to steal it.

    • jrothlander
      jrothlanderApr 14, 2022

      I've ran into things like this a lot over the years. In my experiance you have people that are copy-and-paste style programmers... in that they really do not get what is going on, but make a career out of finding an example and making it work. They actually tend to do a decent job until they run into something they cannot find an example of.

      It is a common pattern I have seen with contractors coming from a few difference countries. Well, that and lying on their resume. A few of them told me they teach classes on how to land a job by exagerating your resume, education, and skills. So it is a pretty big issue really. That's why we started handed people a laptop during an interview and ask them to solve some simple coding problems. If they are exagerating their experiance or skills, we'll figure it out in about 5 minutes... or less.

Add comment