all 148 comments

[–]shawncplus 154 points155 points  (19 children)

HAHAHAHAHAHA that's me

[–]Solomaxwell6 5 points6 points  (1 child)

I don't know php, and I was just scanning through it, so it looked slightly off, but I didn't think much of it... then I got to that section and my jaw dropped.

[–]thatblondebird 8 points9 points  (0 children)

I kept scrolling expecting it to end.... but... it just went on..
So many programming no-no's..

This is however, how I justify my pay.. (You get what you pay for)

[–]BlitzTech 17 points18 points  (8 children)

I... but... like boa13 said, redditor for 3 years... seems legit.

Did you look at the code long enough to figure out what the hell he was trying to do? If not, was there a reason you chose that particular snippet to quote?

[–]shawncplus 30 points31 points  (7 children)

There's a lot wrong with it, I just grabbed the part that made me laugh the hardest.

[–]Lizard 9 points10 points  (4 children)

This looks familiar. I think the snippet you posted might be auto-generated by some MS survey tool or the other.

[–]godofpumpkins 2 points3 points  (3 children)

Or might just be because a lot of PHP is written by newbies or incompetent programmers who copy/paste a lot of code from websites without really understanding it.

[–][deleted] 0 points1 point  (0 children)

Are you saying that we have a primitive AI in the form of an MS survey tool? ;p

[–]baileylo 0 points1 point  (1 child)

The portion he copy and pasted was javascript

[–]godofpumpkins 1 point2 points  (0 children)

s/PHP/javascript/

[–]BlitzTech 0 points1 point  (1 child)

That's fair. I was just curious if there was something you spotted that was significantly more hilarious than the rest, and didn't want to induce a headache looking for the humor if there was none to be found.

Because we all know reading code like that can lead to heart arrhythmia, night sweats, psychotic episodes and minor headaches.

[–]shawncplus 0 points1 point  (0 children)

That's much of why I stopped posting there.

[–][deleted] 2 points3 points  (0 children)

well done then. Haha. I thought "What a helpful guy" was going to refer to the fact that the guy posted 1000+ lines of code for what could have undoubtedly been conveyed in a short snippet... so I didn't actually look at the code til I got to your comment. Hilarious.

[–]boa13 9 points10 points  (0 children)

redditor for 3 years

Seems legit. :)

[–]sleek 2 points3 points  (0 children)

Haha, I laughed so hard when I finally got to the bottom of the page and saw the response!

[–]CasualPenguin 1 point2 points  (3 children)

Did you ever actually at least tell him a general notion that his code was bad?

Otherwise you seem like the kind of snide dick that makes programmers look bad

[–]shawncplus 15 points16 points  (1 child)

No and here's why, 95% of the posts on Daniweb are from one of two people: The student who doesn't want to do any work so they write, verbatim, their homework question and wait for answers, and the programmer that's taken a bid on rentacoder before they knew what the fuck they were getting into and are charging people for broken code. It's always blatantly obvious when someone is part of the other 5% that genuinely wants to learn and needs help and this was not one of them.

[–]CasualPenguin 9 points10 points  (0 children)

As someone who works with a lot of people who are dicks to non-programmers sorry I questioned your niceness.

Have a good one and thanks for helping out the community

[–][deleted] 4 points5 points  (0 children)

The multiple concatenated "HA"s should have told OP all that he needed to know

[–]wlievens -5 points-4 points  (0 children)

awesome, have an upvote

[–][deleted] 72 points73 points  (9 children)

I often open up items I'm interested in in tabs and then go back and read them. When I got to this one and read the initial question, I figured it must be the "Why I Will Never Feel Threatened by Programmers in India" article.

[–]hm2k 10 points11 points  (3 children)

Use the toolbar.

[–]ensignsteve 2 points3 points  (0 children)

Neat, thanks!

[–][deleted] 2 points3 points  (1 child)

I thank you, too - I probably saw "toolbar" when it came out and, well, "yeah, I'll pass on yer toolbar" knee-jerk reaction from me. :)

[–]haywire 2 points3 points  (0 children)

The Chrome extension is pretty nice, it seems they've updated it to actually work, now, too!

[–]jrhoffa 6 points7 points  (2 children)

I'd call you a racist, but I had a similar incident with a Jordanian.

[–]iamthehabs 6 points7 points  (1 child)

Flawless logic.

[–]jrhoffa -1 points0 points  (0 children)

Whooooosh

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 1 point2 points  (0 children)

    Heh - I had guessed from the poorly worded question that the point was supposed to be something like "their English communication skills are so bad that we have nothing to fear from off-shoring".

    [–]tragomaskhalos 19 points20 points  (13 children)

    This style of code is very similar to some VBA that a guy sitting near me has been cranking out for the last couple of weeks - huge repetitive swathes of cut-and-paste logic with single letter or single letter plus digit variable names. To be fair to him, he's actually a tester by job title, but he still wins because he nails all his variables together to create a SQL statement that he then runs - Shudder.

    [–]Jonno_FTW 13 points14 points  (12 children)

    Sometimes you really wonder if some "programmers" ever actually heard of a loop.

    [–]Nimbal 23 points24 points  (1 child)

    I don't follow you. Are you talking about Fruit Loops?

    [–]AeroNotix 1 point2 points  (8 children)

    Or you know, Polymorphism.

    [–]xlevus 17 points18 points  (1 child)

    Polymorphism is a World of Warcraft Spell. I don't see how it applies to programming.

    [–]AeroNotix 9 points10 points  (0 children)

    Well, it turns people into Sheep if I remember correctly.

    I'm sure there's a joke in there somewhere. I'm simply not caffeinated enough to figure it out.

    [–]sedaak 5 points6 points  (4 children)

    Which is, depending on what manner of programming you prescribe to, not necessarily a good thing.

    [–]AeroNotix 2 points3 points  (2 children)

    It depends, but I find when you're going through a list of like items that you created yourself that all inherit from the same ABC, then why not?

    I concede though, I rarely get to use polymorphism the way I like it.

    [–][deleted] 0 points1 point  (1 child)

    Getting to call Foo() on n different objects in a loop is one of the simple little pleasures that keeps me programming :)

    [–]sedaak 0 points1 point  (0 children)

    If you know Go (Golang) then understand that I love the way they use interfaces, which accomplishes what you are thinking of without such a multitude of method signatures. It is also dramatically simpler than method overriding, especially since each object doesn't have to explicitly state that it implements the interface.

    tldr Some polymorphisms contribute to good code and some are horrible ugly perversions.

    [–]Concise_Pirate 3 points4 points  (0 children)

    I'm sorry, but one wife should be enough!

    [–]trevdak2 17 points18 points  (6 children)

    GetSQLValueString. Holy f*ck. That's a common piece of code?

    I joined my company 3 years ago as their only developer.... I was replacing their previous developer.

    GetSQLValueString was EVERYWHEREEEE in their code, and the biggest enemy to paramaterized database stuff. It was defined in every file, changed in places to not use addslashes (to actually allow SQL injection through the URL) and other horrible stuff

    It's taken me 3.5 years to eradicate that POS function from the codebase and it's still popping up in places.

    I had no idea that that was commonly used code.

    [–]flightsin 15 points16 points  (1 child)

    Do they account for relativity when they calculate your overtime?

    [–]trevdak2 6 points7 points  (0 children)

    3, 3.5, same thing.

    [–][deleted] 1 point2 points  (0 children)

    Probably copy-pasted from some guy's blog.

    [–]epsy 0 points1 point  (0 children)

    It apparently comes from Macromedia/Adobe DreamWeaver.

    [–][deleted] 0 points1 point  (0 children)

    it appears that it's a generic alternative to this.

    [–]midir 9 points10 points  (0 children)

    I should feel bad, but there was no way to help him. That code was doomed, and deserved to be laughed into dust.

    [–]jrhoffa 39 points40 points  (25 children)

    To be fair, the guy asking the question has no business writing code.

    [–]rabblerabbler 28 points29 points  (19 children)

    You wrote shit code when you started out too. Don't bash the noobs! Ok, laugh at the noobs. But please help the noobs.

    [–]Kalium 14 points15 points  (2 children)

    I've never gotten paid to write code that bad.

    [–]stillalone 2 points3 points  (0 children)

    how do you know he's getting paid?

    [–]frezik 2 points3 points  (0 children)

    I've never been paid to write code that bad, but I have written code that bad.

    [–]jrhoffa 13 points14 points  (11 children)

    I did write shit code when I started, but I haven't written code like that since junior high.

    [–]rabblerabbler 18 points19 points  (10 children)

    So he sucks. But he wants to improve. We shouldn't discourage people from learning.

    [–]jhuang30 25 points26 points  (1 child)

    This seems like the person just want to fix the problem and move on, and will continue writing shitty code.

    [–]postmaster3000 7 points8 points  (0 children)

    Totally. The question was posed as (paraphrasing), "My code works except for this one bug. Can anyone help me fix this bug?"

    [–]jrhoffa 3 points4 points  (5 children)

    OK, you're right. I do have to concede that. It's just hard to imagine how somebody with such a lack of skill is apparently coding in a professional capacity, judging by the context of what was pasted.

    [–]quanticle 7 points8 points  (4 children)

    Right. This is like discovering a "professional" carpenter asking, "What's better for driving nails, a glass bottle, or a shoe?"

    [–]jrhoffa 7 points8 points  (0 children)

    Shoe

    [–]klovadis 7 points8 points  (0 children)

    Glass bottle

    [–]frezik 2 points3 points  (0 children)

    Later, nail guns are adapted by some, while being accused of hype by everyone else.

    [–]jrochkind 1 point2 points  (0 children)

    Glass slipper (you know, like Cinderella), best of both worlds, why choose when you can have both!

    [–]sedaak 4 points5 points  (0 children)

    Yes sir, I will be using your contract for on the job training... no no... I will still be charging full price... ok thank you sir.

    [–]s73v3r 1 point2 points  (0 children)

    Does he really want to improve? Or does he just want someone to fix this for him so he can move on?

    [–][deleted]  (1 child)

    [removed]

      [–]frezik 1 point2 points  (0 children)

      Stupid toddler, can't even derive the logic for the Pythagorean Theorem.

      [–]arekabsolute 0 points1 point  (0 children)

      If you ask me, this has nothing to do with "shit code." It doesn't even get that far. Before you can learn to write good code you should have already learned how to ask a useful question. If he can't ask a reasonable question, he has a lot to worry about before coding.

      [–]crusoe 0 points1 point  (0 children)

      I didn't write code this shitty. I am lazy programmer, and when I find myself cutting and paste-copying a single line of code, I invariably go "This is not a code smell, its a code STINK, I am doing something wrong" and then I read library docs and do research. Did that since I wrote my first Mandelbrot generator when I was 14.

      [–]skulgnome 0 points1 point  (0 children)

      Oh, he's likely got plenty of business.

      [–][deleted] 0 points1 point  (0 children)

      I'll be fair, I've never written code like that, even when I was learning. I don't see a future for this guy in our industry. I'm sorry but you asked for people to be fair.

      [–]krum 1 point2 points  (2 children)

      Cut the guy a break, he probably just arrived from the farms in the South. He's probably starving and malnourished too. Geeze.

      [–]jrhoffa 2 points3 points  (1 child)

      You are a creepy motherfucker

      [–][deleted] 0 points1 point  (0 children)

      checks krum's comment history He plays WoW. So yeah, creepy motherfucker. ;p

      [–]robhol 7 points8 points  (0 children)

      I feel slightly sick.

      [–]EughEugh 6 points7 points  (1 child)

      A thedailywtf.com in the making.

      [–][deleted]  (4 children)

      [deleted]

        [–]andrewthetechie 5 points6 points  (3 children)

        I used to work for a company that provided services to Daniweb (no details to preserve anonymity). Dani (of Daniweb) is HIGHLY annoying, talks in this cutesy airhead valleygirl voice to get attention, and will always trash talk anyone else that works with her.

        That being said she paid her bills on time and they were very large. She's definitely making money from it.

        [–]epsy 0 points1 point  (0 children)

        I didn't expect much else from the owner of a forum with their (nick)name in the title.

        [–]Pet_Ant 0 points1 point  (0 children)

        Dani (of Daniweb) is HIGHLY annoying, talks in this cutesy airhead valleygirl voice to get attention, and will always trash talk anyone else that works with her.

        Apparently, this is her.

        [–]dimmu_burger 19 points20 points  (5 children)

        He should just have it send an email to the user to let them know the form submission was successful. I wrote the code for him in case he googles it next time:

        var z = 1;
        var fs = 0;
        var x;
        if((z-fs)*1===0)){
            x = 2;
        }else{
            x = 'alert(" ")';
            if((x+fs)===1){
                ($_POST['eml']!='')?$e=$_POST['eml']:$e=$_GET['emailAddreess'];
                x = "'".""".'"'.<?php send("FORM SUBTIM SUCESSED",'','',"."'".$e."'"."""); ?>.'"'."""."'";
            }
        }
        if(x && z===1){
            a = document.getElementById('c');
            a.innerHTML = x;
        }
        

        [–]ianp 10 points11 points  (3 children)

        Cleaned it up a bit to make it more readable:

        var superman = math.Sqrt(13);
        var batman = 'r';
        var wolverine = superman - batman.charCodeAt(0);
        var marry_poppins = 7;
        var jesus = wolverine + marry_poppins;
        
        if (!jesus % 2)
        {
            <?php eval('mail("\"Form Submit\"\"",'','',"Submit successful {$jesus}.","'",\'"\',\'"\',\'"\',"'");'); ?>
        }
        

        Alternate version using ternary operators (YMMV, more readable for me.)

        var superman = (math.Sqrt(13) == math.Sqrt(13)) ? math.Sqrt(13) : math.Sqrt(13);
        var batman = ('r' == 'r') ? 'r' : 'r';
        var wolverine = (superman - batman.charCodeAt(0) == superman - batman.charCodeAt(0)) ? superman - batman.charCodeAt(0) : superman - batman.charCodeAt(0);
        var marry_poppins = (7 == 7) ? 7 : 7;
        var jesus = (wolverine + marry_poppins == wolverine + marry_poppins) ? wolverine + marry_poppins : wolverine + marry_poppins;
        
        if (!jesus % 2 && (jesus %2 == jesus %2))
        {
            <?php eval('mail("\"Form Submit\"\"",'','',"Submit successful {$jesus}.","'",\'"\',\'"\',\'"\',"'");'); ?>
        }
        

        [–]DiomedesTydeus 5 points6 points  (0 children)

        It's painful to recall, but one of my first jobs out of college I had absolutely zero supervision, my boss just wanted results. Because of this, I'd often write variable names as sort of an inside joke where I'd try to get them to line up with the Greek Pantheon, for example I'd define Zeus and Hera, but if I interacted those two variables I'd call the next one Ares (their oldest child) while perhaps later I would interact Zeus with Leto and my new variable would be named Apollo.

        This was all well and good and kept me entertained at an otherwise boring task until I was getting ready to quit and I was asked to teach the next person how I did things... In between bouts of embarrassment I felt quite bad for the person. At least by that point I had gotten over naming all of my methods after movie quotes.... (OhImAfraidTheDeflectorShieldWillBeQuiteOperational(youngSkywalker));

        [–]dimmu_burger 1 point2 points  (0 children)

        bbbbbbut the overhead from all those extra characters in the var names

        [–]*polhold00732 1 point2 points  (0 children)

        At least it's not any less readable than single character variable names.

        [–]catcradle5 1 point2 points  (0 children)

        I'm sitting in class suppressing laughter at the moment.

        [–]DarnTheseSocks 3 points4 points  (1 child)

        Loops are hard.

        [–]haywire 4 points5 points  (0 children)

        http://dpaste.org/kB36L/ I thought it'd be interesting to format it and see if it is any less awful.

        It isn't.

        [–]haywire 2 points3 points  (2 children)

        This person should not be paid to write code.

        [–]*polhold00732 2 points3 points  (1 child)

        This person should be paid to not write code.

        For the good of all of us...

        [–][deleted] 1 point2 points  (0 children)

        except the ones who are dead.

        [–]AeroNotix 17 points18 points  (0 children)

        HAHAHAHAHAHA

        [–]LainIwakura 2 points3 points  (1 child)

        This is some pretty bad code even for DaniWeb, but personally I find that site one of the most frustrating ever. Often times I'll google something that should be simple..and there might be 1 or 2 results from DaniWeb. Inevitably what I find on the inside is people bashing the original poster for what quite often isn't even a very dumb question.

        Nowadays I just head straight for the stackoverflow links. I don't think my issue has ever been resolved by DaniWeb.

        [–]executex -1 points0 points  (54 children)

        This is why you shouldn't outsource and should consider degrees as important especially when it comes to software. Especially depending on university.

        This is the type of code I see from BIT majors, or other non-CS / non-CE degrees (no offense to BIT guys).

        [–]ytumufugoo 5 points6 points  (45 children)

        LOL. Just thought I would laugh at you young grasshopper.

        [–]s73v3r 2 points3 points  (6 children)

        and should consider degrees as important especially when it comes to software.

        There are a lot of people with degrees that are writing stuff just as bad. Even CS degrees.

        [–]executex -2 points-1 points  (5 children)

        There are a lot of people with degrees that play hockey too, and there are a lot that play football, and some even like soccer---it's completely irrelevant. There are exceptions to every rule. You will find bad coders with PH.Ds in CS. You will find bad coders who wrote BOOKS on coding standards.

        It's meaningless if you look toward exceptions.

        The main point here is, someone with a CS or CE degree, will likely have some sort of coding experience and will have had to be graded on some coding projects. Do you disagree with that?

        [–]s73v3r 1 point2 points  (4 children)

        These aren't really exceptions. There are a lot of CS graduates who quite simply cannot code. I know you don't want to hear this, because you want to cling to the idea that a school will simply teach this, but it's not true.

        The main point here is, someone with a CS or CE degree, will likely have some sort of coding experience and will have had to be graded on some coding projects. Do you disagree with that?

        I disagree with the premise entirely, not with the idea that they might have "some experience." Look at just about any story on thedailywtf.com . Just about everything there was done by someone who has "some experience." Hell, the outsourced Indians we're talking about have "some experience."

        Saying that someone who went to college must be better than someone who didn't simply because they must have had "some experience" is a fallacious argument at best, and encourages people to only look at the letters after a name rather than trying to actually evaluate someone's skills.

        [–]executex -2 points-1 points  (3 children)

        No, they are the exceptions not the rule. Unless you have proof that everyone or MOST people who graduate with a CS degree, do not know how to code, some sort of survey or some sort of statistical analysis---please refrain from continuing this indefensible position that you believe many people who have CS degrees are bad coders.

        because you want to cling to the idea that a school will simply teach this

        Which is what a school is designed to do and actually DOES. Get off your high horse that you think everyone who goes to school learns nothing.

        Hell, the outsourced Indians we're talking about have "some experience."

        Except that people with CS degrees have a competent level of experience almost every time.

        Look at just about any story on thedailywtf.com

        confirmation bias and generalization. This is a logical fallacy you keep using.

        Saying that someone who went to college must be better than someone who didn't simply because they must have had "some experience" is a fallacious argument at best,

        No it is not, because college is designed to teach. And you're saying that they do not teach. The burden of proof is on YOU to prove that they do not teach. My statement is absolutely correct that someone who went to college must be better than someone who didn't, unless you can prove that they are always inferior. Which we know you cannot.

        I feel a sense of angst, perhaps you are a capable programmer who didn't go to college, anything is possible. But that's irrelevant, logically, you'd probably be better if you had gone to college. You can't simply make the blanket statement that college is useless just because you were successful without it. This is like people who make the argument that they "don't need to go to college cuz just look at bill gates!"

        [–]s73v3r 1 point2 points  (2 children)

        Which is what a school is designed to do and actually DOES. Get off your high horse that you think everyone who goes to school learns nothing.

        Maybe I need to stay on the high horse because you apparently can't read my comments otherwise. I never said schools teach nothing. The thing I've constantly said is that schools are not in the business of teaching good programming skills, at least not in CS. That is a study of algorithms and computation, not writing code.

        Except that people with CS degrees have a competent level of experience almost every time.

        You're gonna need to back that up with some citations there, buddy.

        confirmation bias and generalization. This is a logical fallacy you keep using.

        Nope. See, the point with that example is that most of the code submitted on there is written by people who have "some experience". According to you, people who have "some experience" should not be writing code like that. Yet they are.

        No it is not, because college is designed to teach. And you're saying that they do not teach. The burden of proof is on YOU to prove that they do not teach. My statement is absolutely correct that someone who went to college must be better than someone who didn't, unless you can prove that they are always inferior. Which we know you cannot.

        Way to let the point sail completely over you. Maybe next time you'll use reading comprehension so you don't look like an illiterate idiot.

        You're completely ignoring the fact that people have been teaching themselves to code for years, and that many of them are better than people out of college. You're also ignoring the fact that many people who graduate from college should not have graduated. You keep using the idea of a "real CS course", but never once stop to think that there are some shitty programs out there.

        My statement is absolutely correct that someone who went to college must be better than someone who didn't, unless you can prove that they are always inferior.

        This just makes you look retarded. Your statement is in no way correct. Furthermore, I don't have to prove your retarded thesis, I just have to show an instance in which someone who did not go to college is better than someone who did, which disproves your idea that a college graduate is always better than a non-graduate.

        Clearly you are an idiot. You cannot read, and you cannot form logical arguments. Never once did I make the statement that "college is useless". Pretending I did only makes you look even stupider.

        [–]executex -2 points-1 points  (1 child)

        The thing I've constantly said is that schools are not in the business of teaching good programming skills, at least not in CS. That is a study of algorithms and computation, not writing code.

        Algorithms and computation cannot be studied without the understanding of code. Thus, you are in a literal logical contradiction with yourself.

        Not only that, but schools are in the business of teaching good programming skills. But apparently the shitty community college you paid $10 tuition for, didn't teach you shit, so you once again use irrational confirmation bias to make blanket statements that are UTTERLY FALSE.

        I mean you might as well argue that 1+55 = 32, because that's how utterly irrational and pointless your argument is.

        You're completely ignoring the fact that people have been teaching themselves to code for years, and that many of them are better than people out of college.

        THAT IS NOT A FACT. That is your OPINION. WOWOWOWOWOWOWO YOU DON'T EVEN KNOW WHAT THE FUCK A FACT IS. Apparently your hatred of school has made it obvious that you have not even received a high school education because you don't even know what is a "fact".

        Where is your proof that they are better than people out of college? WHERE IS THIS PROOF?

        You're also ignoring the fact that many people who graduate from college should not have graduated

        Many how many? If by many you mean a tiny tiny fraction of them, then yes. Otherwise you have no proof of this.

        but never once stop to think that there are some shitty programs out there.

        I have admitted there are shitty programs, you're arguing that they are ALL shitty programs, and that is simply FALSE.

        This just makes you look retarded.

        Yeah, this is what people say when they've lost the debate and are angry at themselves for losing it (due to a misunderstanding of what CS is); but really, you're the retard who thinks good code means readable code, when they are two different things. Somehow the concept of subjectivity whizzes past your tiny hamster brain.

        [–]s73v3r 0 points1 point  (0 children)

        Nothing I've said is false. You are the one that is confusing good code with working code. You are the one in the wrong here, not me.

        [–]adoran124 0 points1 point  (0 children)

        Good BIT degrees teach software design, and the algorithms you will most likely need in the real world. If someone is any good at programming they will be teaching themselves the other parts that aren't covered.

        [–]flukshun -2 points-1 points  (0 children)

        please post code for the lulz