- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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...
Admin
OMGWTF !!!
Admin
Since when did they allow people who don't know how to code..at all.. into program development?
oh wait....
Admin
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!)
Admin
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
Admin
I think for $300 I'd have found an open source survey app and spent two hours customizing it.
Admin
Yeesh.
Admin
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.
Admin
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 ;)
Admin
Imagine you get this code with the request to add a new education level.
The horror! [email protected]
Admin
Very thorough! It even takes into account the difference between no response and "no answer."
Admin
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
Admin
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.
Admin
Maybe it is an unrolled loop for speed optimization :-)
Admin
The real WTF is he uses many IF statements instead of an IF-ELSE IF chain.
CAPTCHA: tastey indeed!
Admin
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!
Admin
$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 . "
"; }
Admin
I wouldn't have coded any of the radio buttons once...
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.
Admin
$300? Madness? THIS IS SPARTA!!
Admin
Indian Motto: Work harder, not smarter.
Admin
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!
Admin
lol
Admin
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.
Admin
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?".
Admin
Loops are for weenies.
Admin
In programming, correctly applied laziness is a virtue, not a vice.
Admin
A CodeSOD I understand! :) If nothing else, at least now I can die happy thanks to these guys.
Admin
I think you can make a less controversial statement: Some people just shouldn't be allowed to code... ever.
Admin
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.
Admin
Admin
Imagine the fun if they needed to expand the list to, say 20 different options!
Admin
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.)
Admin
Yeah, gotta do that with interpreters...
Admin
Ah, the wonders of mindless outsourcing...
Admin
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.
Admin
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!!
Admin
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.
Admin
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...
Admin
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:
Admin
I've seen this kinda code before plenty of times. Usually it was in classic ASP :)
Admin
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.
Admin
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?
Admin
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.
Admin
helloo !!! what happens to good coding practice???
<input type="radio" name="EducationID" value="High school" checked
High school
Admin
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"
Admin
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.
Admin
Yep... I agree. You just want to shout at some people: "Step away from the compiler... Before someone gets hurt!"
Admin
Better yet, localization, which is even more likely.
Admin
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.
Admin
I have seen code like this.
In production. From an internal source.
It makes me weep.