Comment On Only $0.001 per Line

Generally speaking, $300 doesn’t go very far in the world of custom software. If you’re lucky, it might be enough to fix a typo in a production application. These days, with the advent of IT Project Portals (as discussed before) that provide everyone access to certain developers from certain countries, $300 can go a long way. Not long enough to build working software, of course, but surely long enough to generate lots and lots of worthless code. At least, that was the experience with Christopher’s client. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Only $0.001 per Line

2007-09-17 09:34 • by Novus
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...

Re: Only $0.001 per Line

2007-09-17 09:35 • by poupilos (unregistered)
OMGWTF !!!

Re: Only $0.001 per Line

2007-09-17 09:42 • by codemonkey (unregistered)
Since when did they allow people who don't know how to code..at all.. into program development?

oh wait....

Re: Only $0.001 per Line

2007-09-17 09:53 • by 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!)

Re: Only $0.001 per Line

2007-09-17 09:54 • by 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

Re: Only $0.001 per Line

2007-09-17 10:02 • by shakin
153511 in reply to 153510
I think for $300 I'd have found an open source survey app and spent two hours customizing it.

Re: Only $0.001 per Line

2007-09-17 10:02 • by Quintin (unregistered)
Yeesh.

Re: Only $0.001 per Line

2007-09-17 10:04 • by 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.

Re: Only $0.001 per Line

2007-09-17 10:08 • by 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 ;)

Re: Only $0.001 per Line

2007-09-17 10:10 • by mielvanacker (unregistered)
Imagine you get this code with the request to add a new education level.

The horror!
miel.vanacker@defraine.net

Re: Only $0.001 per Line

2007-09-17 10:14 • by Susanna (unregistered)
Very thorough! It even takes into account the difference between no response and "no answer."

Re: Only $0.001 per Line

2007-09-17 10:14 • by jbosss (unregistered)
153518 in reply to 153509
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

Re: Only $0.001 per Line

2007-09-17 10:14 • by bighusker (unregistered)
153519 in reply to 153510
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.

Re: Only $0.001 per Line

2007-09-17 10:17 • by Christof (unregistered)
Maybe it is an unrolled loop for speed optimization :-)

Re: Only $0.001 per Line

2007-09-17 10:24 • by codemonkey (unregistered)
The real WTF is he uses many IF statements instead of an IF-ELSE IF chain.

CAPTCHA: tastey indeed!

Re: Only $0.001 per Line

2007-09-17 10:27 • by Drum D.
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!

Re: Only $0.001 per Line

2007-09-17 10:30 • by shadowman
153524 in reply to 153519
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 . "<br />";
}

Re: Only $0.001 per Line

2007-09-17 10:34 • by stutter (unregistered)
153525 in reply to 153519
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; ?><br />
<?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.

Re: Only $0.001 per Line

2007-09-17 10:36 • by Vechni
$300? Madness? THIS IS SPARTA!!

Re: Only $0.001 per Line

2007-09-17 10:36 • by Justin Buist (unregistered)
Indian Motto: Work harder, not smarter.

Re: Only $0.001 per Line

2007-09-17 10:48 • by Vechni
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!

Re: Only $0.001 per Line

2007-09-17 10:54 • by that was funny (unregistered)
153529 in reply to 153526
lol

Re: Only $0.001 per Line

2007-09-17 11:00 • by 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.

Re: Only $0.001 per Line

2007-09-17 11:00 • by 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?".

Re: Only $0.001 per Line

2007-09-17 11:02 • by SenorLapiz
Loops are for weenies.

Re: Only $0.001 per Line

2007-09-17 11:03 • by brazzy
153534 in reply to 153527
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.

Re: Only $0.001 per Line

2007-09-17 11:12 • by Adam (unregistered)
A CodeSOD I understand! :) If nothing else, at least now I can die happy thanks to these guys.

Re: Only $0.001 per Line

2007-09-17 11:15 • by CornedBee
153538 in reply to 153509
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.

Re: Only $0.001 per Line

2007-09-17 11:16 • by 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.

Re: Only $0.001 per Line

2007-09-17 11:38 • by ParkinT
153545 in reply to 153539
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.

Re: Only $0.001 per Line

2007-09-17 11:51 • by snoofle
153550 in reply to 153530
Imagine the fun if they needed to expand the list to, say 20 different options!

Re: Only $0.001 per Line

2007-09-17 11:56 • by phaedrus
153554 in reply to 153534
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.)

Re: Only $0.001 per Line

2007-09-17 11:58 • by Nirav (unregistered)
153555 in reply to 153521
Yeah, gotta do that with interpreters...

Re: Only $0.001 per Line

2007-09-17 12:00 • by Renan "C#" Sousa
Ah, the wonders of mindless outsourcing...

Re: Only $0.001 per Line

2007-09-17 12:01 • by Ancient_Hacker
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.

Re: Only $0.001 per Line

2007-09-17 12:03 • by 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!!

Re: Only $0.001 per Line

2007-09-17 12:29 • by vt_mruhlin
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.

Re: Only $0.001 per Line

2007-09-17 12:36 • by 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...

Re: Only $0.001 per Line

2007-09-17 13:04 • by 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<br>
<input type="radio" name="EducationID" value="Some college" <?=($_SESSION['EducationID'] == 'Some college')?'checked':''?>>Some college<br>
//etc etc etc

Re: Only $0.001 per Line

2007-09-17 13:18 • by WTFer (unregistered)
I've seen this kinda code before plenty of times. Usually it was in classic ASP :)

Re: Only $0.001 per Line

2007-09-17 13:19 • by Mexi-Fry
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.

Re: Only $0.001 per Line

2007-09-17 13:21 • by 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?

Re: Only $0.001 per Line

2007-09-17 13:25 • by Mexi-Fry
153580 in reply to 153561
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.

Re: Only $0.001 per Line

2007-09-17 14:34 • by me (unregistered)
helloo !!! what happens to good coding practice???

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

>
High school
<br>

Re: Only $0.001 per Line

2007-09-17 14:43 • by joh6nn (unregistered)
153588 in reply to 153525
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; ?><br />
<?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"

Re: Only $0.001 per Line

2007-09-17 14:53 • by omgitsfletch
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.

Re: Only $0.001 per Line

2007-09-17 15:07 • by SenorLapiz
153593 in reply to 153538
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!"

Re: Only $0.001 per Line

2007-09-17 15:15 • by fanha (unregistered)
153595 in reply to 153516
Better yet, localization, which is even more likely.

Re: Only $0.001 per Line

2007-09-17 15:23 • by Mot (unregistered)
153596 in reply to 153591
>>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.

Re: Only $0.001 per Line

2007-09-17 15:24 • by Tukaro
I have seen code like this.

In production. From an internal source.

It makes me weep.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment