• (cs)

    The worst part is, the varying spacing before "checked" suggests this was manually edited after copy-and-paste. It would have been just a little bit less WTF if it were automatically generated...

  • poupilos (unregistered)

    OMGWTF !!!

  • codemonkey (unregistered)

    Since when did they allow people who don't know how to code..at all.. into program development?

    oh wait....

  • (cs)

    Some people just shouldn't be allowed to code PHP... ever.

    (Ok, so I know the overwhelming majority of people on here probably think NOBODY should be allowed to code PHP ever, but it's what I do for a living, so there!)

  • joh6nn (unregistered)

    definitely a WTF, but i think for only $300, i'd have done the same thing (except without the errors, i hope). when the most you can hope to make on a project is a fraction of what it's worth, then it's in your best interest to complete the project with as little time spent on it as possible. from a "time spent" perspective, this copy-paste monstrosity is probably a lot faster than actually good solution.

    i don't think the WTF here is that someone wrote this, or even that they managed to screw up copying and pasting. what's truly worse than failure is that you can graduate with an MBA, and somehow still think that a multi-thousand dollar clean-up is better than having done it right the first time, because when you do it wrong, your initial investment is only $300 and the clean-up is just maintenance

  • (cs) in reply to joh6nn

    I think for $300 I'd have found an open source survey app and spent two hours customizing it.

  • Quintin (unregistered)

    Yeesh.

  • codemonkey (unregistered)

    There are so many people now-a-days that graduate "stupid", in my experience. It seems particularly prevalent in business related degrees. They get fantastic grades in all their classes and graduate top of their class, and yet have no real world knowledge and end up futzing up the simplest of concepts...like paying a little extra to get the job done right.

  • Bo Stig Christensen (unregistered)

    The best part is the end-PHP and start-PHP consecutive lines.... buahaha....

    Well.... this guy miiiight actually be a good programmer (although not for sure at all!).... He's definately a good salesman (with a bit of a naive customer).

    I don't consider myself a bad programmer at all, but I could also do crap like this.... hehe.... nice $-model for doing zombie-no-brainer-work..... ROFLMAOx2 ;)

  • mielvanacker (unregistered)

    Imagine you get this code with the request to add a new education level.

    The horror! [email protected]

  • Susanna (unregistered)

    Very thorough! It even takes into account the difference between no response and "no answer."

  • jbosss (unregistered) in reply to MrTufty
    MrTufty:
    Some people just shouldn't be allowed to code PHP... ever.

    (Ok, so I know the overwhelming majority of people on here probably think NOBODY should be allowed to code PHP ever, but it's what I do for a living, so there!)

    allow me to correct: Some people just shouldn't be allowed to code... ever.

    IMHO what that person did should not be considered coding. this is just office work of copy&paste

    CAPTCHA: smile - what a happy day

  • bighusker (unregistered) in reply to joh6nn
    joh6nn:
    from a "time spent" perspective, this copy-paste monstrosity is probably a lot faster than actually good solution.

    I really don't see how this is faster than coding each radio button once and determining if it should be checked within each radio button tag. The only person who would do something this way is a person without any real web development experience.

  • Christof (unregistered)

    Maybe it is an unrolled loop for speed optimization :-)

  • codemonkey (unregistered)

    The real WTF is he uses many IF statements instead of an IF-ELSE IF chain.

    CAPTCHA: tastey indeed!

  • (cs)

    Pain, unbelievable pain. Reading these lines is like having red hot needles stuck into my eyes.

    I may have done horrible things in my early PHP days but never something like THAT!

  • (cs) in reply to bighusker
    bighusker:
    joh6nn:
    from a "time spent" perspective, this copy-paste monstrosity is probably a lot faster than actually good solution.

    I really don't see how this is faster than coding each radio button once and determining if it should be checked within each radio button tag. The only person who would do something this way is a person without any real web development experience.

    $education = array("High School","Some College"); // and so forth

    foreach ($education as $ed) { print "<input type='radio' name='EducationID' value='" . $ed . "' "; if ($_SESSION["EducationID"]==$ed) print "checked"; print " />" . $ed . "
    "; }

  • stutter (unregistered) in reply to bighusker
    bighusker:
    joh6nn:
    from a "time spent" perspective, this copy-paste monstrosity is probably a lot faster than actually good solution.

    I really don't see how this is faster than coding each radio button once and determining if it should be checked within each radio button tag. The only person who would do something this way is a person without any real web development experience.

    I wouldn't have coded any of the radio buttons once...

    <?php $educationLevls = array ('1', '2', '3'); ?>
    <?php foreach ($educationLevels as $level): ?>
      <input type="radio" name="EducationID" value="<?= $level; ?>" <?= !empty($_POST['EducationID']) && $_POST['EducationID'] == $level ? 'checked' : ''; ?>>
    <?= $level; ?>
    <?php endforeach ;?>

    no reason to code any of the specific radio buttons any number of times, they're all the same. And that took less time than copying/pasting/modifying. In no scenario is the code "Christopher" wrote acceptable, there is not even a single excuse for it.

  • (cs)

    $300? Madness? THIS IS SPARTA!!

  • Justin Buist (unregistered)

    Indian Motto: Work harder, not smarter.

  • (cs)

    Actually, regarding copy and paste:

    -I probably copy+paste 80% of my code (J2EE) but thouroughly edit it (a quick template), it is simply faster than typing everything and creating solutions for what has already been solved many times. -Code solutions are uniform, very good readability. -Fast developement, writing an entire class by hand would be ridiculous. -Uniform webpages, obviously a goal

    Also, I don't think there is a readiblity difference between using if statements and not using if-else... Infact that is more readable than a loop, but more typing. Thinking outside of the box damnit!

  • that was funny (unregistered) in reply to Vechni

    lol

  • wtf (unregistered)

    well it makes sense really... they do get payed by the line, after all. i'm surprised they didn't combine this with a few other select controls... for example, with just one more select with 6 options, you'd get 6x7=42 different cases. imagine if there were a dozen select fields.

  • Tom Melly (unregistered)

    What always surprises me about this sort of code is that it implies that the coder never, apparently, said to themselves "surely there must be a better way?".

  • (cs)

    Loops are for weenies.

  • (cs) in reply to Justin Buist
    Justin Buist:
    Indian Motto: Work harder, not smarter.
    That's exactly it. If you're able to afford the luxury of boredom, you're much more likely to refuse doing something repetitive and thereby find a better solution than the straightforward bad one.

    In programming, correctly applied laziness is a virtue, not a vice.

  • Adam (unregistered)

    A CodeSOD I understand! :) If nothing else, at least now I can die happy thanks to these guys.

  • (cs) in reply to MrTufty
    MrTufty:
    Some people just shouldn't be allowed to code PHP... ever.

    (Ok, so I know the overwhelming majority of people on here probably think NOBODY should be allowed to code PHP ever, but it's what I do for a living, so there!)

    I think you can make a less controversial statement: Some people just shouldn't be allowed to code... ever.

  • Joe Schmoe (unregistered)

    Ugh. Web development at it's well, at its normal state. I hate to say it but I've seen much worse (production code) and much better.

    Might be a younger programmer with not much experience or many PHP projects.

  • (cs) in reply to Joe Schmoe
    Joe Schmoe:
    Might be a younger programmer with not much experience or many PHP projects.
    It goes beyond that! This is a mediocre HTML developer, with no understanding of scripting languages, using PHP incorrectly.
  • (cs) in reply to wtf

    Imagine the fun if they needed to expand the list to, say 20 different options!

  • (cs) in reply to brazzy
    brazzy:
    In programming, correctly applied laziness is a virtue, not a vice.

    This is, of course, the kind of laziness that compels one to write a 250 line script to avoid typing 15 characters.

    As in I recently wrote a web app in PHP so that some of our managers would stop tracking prototype inventory with an Excel Database... I did a lot of one-off scripting to pre-load the excel spread sheet into MySQL (I'm running Linux+CrossOver Office). It took a decent bit of time, but I wouldn't have finished if I had entered everything by hand due to stabbing out my eyes. (It probably did take a third of the time to script it than just enter stuff by hand, and it's less error prone. And I still have my eyes.)

  • Nirav (unregistered) in reply to Christof

    Yeah, gotta do that with interpreters...

  • (cs)

    Ah, the wonders of mindless outsourcing...

  • (cs)

    reminds me of a program written by a consultant-- lots and lots of code. Mostly copy and pasted 33 times. Impossible to understand or maintain.

  • laughinggrrl (unregistered)

    I've seen, in production...

    An interest form with the standard name/address/phone/email/comments/etc..

    Validation performed server-side.. like this:

    /* we have to make variables by hand here because SOMEONE decided to brake [sic] php by turning off register globals.. */

    $field1 = $HTTP_POST_VARS['field1']; $field2 = $HTTP_POST_VARS['field2']; ... etc.

    if ($field1 != '') $field1OK = "yes"; else $field1OK = "no";

    if ($field2 != '') $field2OK = "yes"; else $field1OK = "no";

    ... and so on

    switch ($field1OK) { case ("no"): /* output form here */ break; case ("yes"): break; }

    switch ($field2OK) { case ("no"): /* output form here */ break; case ("yes"): break; }

    ... and so on...

    You should see the code that generates the dropdown box for the state...

    any guesses as to the output of such a concoction??

    captcha: howdy ... well, howdy pardner!!

  • (cs)

    Brillant! The sad thing is some manager will look at how much time/money Christopher spent on the project, compared to how much time/money the other guys spent, and will fire Christopher for being inefficient.

  • Theo (unregistered)

    I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line... I wish all comments here would be paid per line...

  • Nodren (unregistered)

    i wouldn't have done a loop for this, since they are not likely to ever add to that basic list, it would of made more sense printed out(for better code readability)

    i would do it like this:

    <input type="radio" name="EducationID" value="High school" <?=($_SESSION['EducationID'] == 'High School')?'checked':''?>>High school
    <input type="radio" name="EducationID" value="Some college" <?=($_SESSION['EducationID'] == 'Some college')?'checked':''?>>Some college
    //etc etc etc
  • WTFer (unregistered)

    I've seen this kinda code before plenty of times. Usually it was in classic ASP :)

  • (cs)

    I just had some dude telling me that programmers are a dime-a-dozen. I suspect that he would be very happy with such insightful code as that. Sad thing is, he claims to be a "development company" and hires programmers for <$17/hr.

  • Steve (unregistered)

    As a database programmer, am I the only one who thinks it strange that they use descriptive strings for IDs? "High school"? What kind of ID is that? I know the article said they set all columns as VARCHARs, but you can still put numbers in VARCHARs...at the very least, couldn't they have made it "HighSchool" or something?

  • (cs) in reply to laughinggrrl

    how about this for .Net code

    Dim NameParts() As String = sParam.Split( "." ) select case NameParts.Length case 1 Dim ctl As Control = Page.Controls.FindControl( NameParts(0) ) ''' code here case 2 Dim ctl As Control = Page.Controls.FindControl( NameParts(0) ).Controls.FindControl(NameParts(1)) ''' code here case 3 ''' I think you get the point end select


    I would like to point out that the guy who wrote that code is actually very talented... I suspect that he was just a little frustrated at having to work with VB at the time.

  • me (unregistered)

    helloo !!! what happens to good coding practice???

    <input type="radio" name="EducationID" value="High school" checked

    High school

  • joh6nn (unregistered) in reply to stutter
    stutter:
    bighusker:
    joh6nn:
    from a "time spent" perspective, this copy-paste monstrosity is probably a lot faster than actually good solution.

    I really don't see how this is faster than coding each radio button once and determining if it should be checked within each radio button tag. The only person who would do something this way is a person without any real web development experience.

    I wouldn't have coded any of the radio buttons once...

    <?php $educationLevls = array ('1', '2', '3'); ?>
    <?php foreach ($educationLevels as $level): ?>
      <input type="radio" name="EducationID" value="<?= $level; ?>" <?= !empty($_POST['EducationID']) && $_POST['EducationID'] == $level ? 'checked' : ''; ?>>
    <?= $level; ?>
    <?php endforeach ;?>

    no reason to code any of the specific radio buttons any number of times, they're all the same. And that took less time than copying/pasting/modifying. In no scenario is the code "Christopher" wrote acceptable, there is not even a single excuse for it.

    yeah, but you're missing my point. i'm not defending the above as good, or even acceptable code. i'm saying that, from a time-spent-writing-it point of view, the code above is pretty fast. and without actually timing the various approaches, my guess is going to be that it actually takes less time to write than most "correct"* approaches, especially if you're using a reasonable editor. in particular, one major benefit the code has, is that it requires almost no thought to implement. the other snippets that have been posted as solutions all require some forethought, and maybe a quick jot to php.net to remind yourself of syntax, if you don't use php daily.

    *where "correct" is defined as "a solution that does not induce vomiting"

  • (cs)

    Guys, this kind of brings up a side question I have. What is the best way to get into a real PHP programmer job? I'm 20, in college, and been freelancing on these crappy job portal sites for a while now. I get outbid by programmers like this, and I know I'm not working for near the amount I should be.

    I don't profess to be a PHP guru, but I certainly write better code than this slop. Even if it was just an entry level programming job, anything beats the slave wage work you find on some of the sites out there. Any job I've applied at in the area, I don't hear anything back. Maybe it's because I'm a "freelancer", maybe it's because I don't have an official CS degree, maybe it's my age, maybe it's something else. Is there any way for someone who's self taught to earn a fair wage programming in a situation like mine?

    //PS: I'm majoring in Engineering at the moment, but seriously considering switching to computer science, going major/minor, etc.

  • (cs) in reply to CornedBee
    CornedBee:
    MrTufty:
    Some people just shouldn't be allowed to code PHP... ever.

    (Ok, so I know the overwhelming majority of people on here probably think NOBODY should be allowed to code PHP ever, but it's what I do for a living, so there!)

    I think you can make a less controversial statement: Some people just shouldn't be allowed to code... ever.

    Yep... I agree. You just want to shout at some people: "Step away from the compiler... Before someone gets hurt!"

  • fanha (unregistered) in reply to mielvanacker

    Better yet, localization, which is even more likely.

  • Mot (unregistered) in reply to omgitsfletch

    What is the best way to get into a real PHP programmer job? I'm 20, in college, and been freelancing on these crappy job portal sites for a while now.

    Answer: Find a project you like, maybe sugarcrm.com or something, written in PHP. Join the community. Contribute to the community. Be able to answer newbie's questions, do it graciously. Help people debug their stuff, contribute stuff, extend other people's stuff. Never flame, denigrate, etc.

    Once you get a reputation as either 'helpful' or 'an expert' (hopefully both) you will have a group of people who work in the field ready to recommend you - to real jobs that pay real money.

  • (cs)

    I have seen code like this.

    In production. From an internal source.

    It makes me weep.

Leave a comment on “Only $0.001 per Line”

Log In or post as a guest

Replying to comment #:

« Return to Article