Funny Code


 

I won’t say much about these other than some of them are downright hilarious.

I’ve seen things like this in my past programming days and I’m probably guilty of one or two myself. When you’ve been up all night coding, sometimes your brain just doesn’t work right.

There’s probably even been a time or two when I forgot to remove my debugging code for production and ended up with strange variables and output that shouldn’t be seen by an end user. Oops.

I didn’t read through every one of them, but from the ones I did, this is my favorite:

Once I had a junior programmer writing VB code that needed to know the day of the week. He decided to write his own code, and read something like:

 if (day = 1) or (day = 8) or (day = 15) or (day = 22) or (day = 29) then
 weekday = "Monday"
 elseif (day = 2) or (day = 9) or (day = 16) or  (day = 23) or (day = 30) then
 weekday = "Tuesday"
 ...

Trying to be educational I asked him for his opinion about his own code, and he said that he would simply modify it every month.

– PedroChan


 

6 Responses to Funny Code

  1. JC says:

    “ended up with strange variables and output that shouldn’t be seen by an end user”

    My favorite has to be when I was having problems with a variable not refreshing its contents from page to page, it was maintaining old contents… so I reset the scope from whatever-it-was.lasthistid to “fingerscrossed.lasthistid”
    it worked
    I didn’t touch it afterwards. Who am I to argue with the fates?
    but occasionally it shows up in the output if they somehow manage to bring really bad data in at that point. I laugh every time I see it, but I haven’t bothered fixing it yet.

  2. Brilliant! For more laughable code like this you should check out: http://thedailywtf.com/

  3. Jesus says:

    Why is it that so many braindead code examples come from VB programmers?

    he said that he would simply modify it every month

    That quote make me lol :D

  4. oldman says:

    i don’t get it…

  5. Not a geek says:

    No, I don’t know what it’s like to code all night long. I have a life. All night long is normally spent drinking with mates. Not coding. And yes I get the joke. But it’s not funny. No offence but I suggest you all go out and get a life and a girlfriend/boyfriend. Good luck with that :)

  6. @Not a geek

    So people who think this is funny apparently don’t have a life and/or girlfriend? Cause I’m pretty I have both.

    Just wish I was as cool as you lol.

Leave a Comment

Your email address will not be published.

*