I never thought I’d see PHP this bad in 2008
April 6, 2008
I started a small ‘quick fix’ project for a client the other day. He had outsourced development of a small ecommerce site to a company in India. He had originally outsourced (via guru I think) the design to someone in Brazil and had good results, so then outsourced again, and has been burned so bad it’s not funny. In his defense, he said he’d talked to some US based companies but they’d wanted, what he thought, too much money (we’re talking quotes over $6k for an ecommerce site to sell less than 5 products – no fancy needs at all). While in 2008 I’d probably agree that that’s a bit on the high side, the alternative he got was far worse, in that he’s out 3 months of product sales and marketing opportunities, still isn’t launched, and has a hell of a bad codebase.
Here’s an example in a ’signin-3.php’ file (yes, there’s ’signin-2.php’ which represents an earlier version, etc.).
<select name=”state” style=”width:70px” >
<option value=”">Select</option>
<?
if($ss==”AA”)
{?>
<option value=”AA” selected>AA</option>
<option value=”AA”>AA</option>
<option value=”AB”>AB</option>
….
<option value=”WY”>WY</option>
<option value=”YT”>YT</option>
<? }
?>
<?
if($ss==”AE”)
{?>
<option value=”AA” >AA</option>
<option value=”AE” selected>AE</option>
<option value=”AK”>AK</option>
…
and on it continues for another 3500+ lines of crap code. This had to have been done by hand (well probably copy/paste) cause I can’t imagine someone being sharp enough to write a generator script for this boilerplate code not also being able to say ‘ why don’t I just run the generator code on the page itself’.
I certainly know that not all ‘outsourced’ (read, Indian, Eastern European, non-US based, etc.) code is this bad, but it seems a fair amount of projects I’ve come across, directly or indirectly, that had been done outside the US/Canada/UK are done at about this level.
So why is this the case? People will usually opt for cheaper prices in almost all cases, unless they can clearly understand the (vast) differences in quality they’ll be getting. To most people code is code, and I still struggle with how to explain differences to non-tech people some times. I *know* the example above is bad, but *why*? In an objective sense, I don’t have to touch it – it ‘works’, so why do I complain about it? Why not just shut up and ‘fix’ the site so it ‘works’? My initial reaction to my own question is because this code indicates a level of quality that is rampant throughout the rest of the code as well, and as such, the rest of the code I need to ‘fix’ is at least as bad (and therefore difficult) to ‘fix’ without rewriting large chunks.
I just finished the bulk of a moderately large project last week which also had a bunch of bad code in it, but I was able to not touch chunks of it because there was *some* degree of separation. There were some classes, some templating separation, etc. Enough so that I could focus (mostly) on just the pieces I needed to. The current project (exampled above) has no such structure. Every ‘page’ has a full HTML header/footer repeated on it, function definitions mixed in to the HTML, class definitions repeated on nearly every page (”class Pager” defined 40 times!) and so on. I’m again fighting the urge to say ’scrap it and start over’ but it’s pretty difficult to do that.
Feel free to reply with your own horror stories, advice, input, etc. I don’t know what I’ll do yet. To the client’s credit, he’d outlined in great detail the remaining 6 issues – screenshots, corrected text, explanations of what the functionality should be – and based on that I’d given him a moderate estimate, which I can still likely hit. *Long term*, however, as in, if anyone (me or whoever) has to go back and touch this code, it’ll be a nightmare, and whoever it is, if they’re US/Canada/UK based, will likely recommend to start over. If it’s a third rate Indian company, they’ll likely just take it, charge $8/hour for 5 months, and slog through it manually. Is that a bit harsh? Maybe, but it’s been my experiences so far. :/
BTW, I’ll not name names (yet) as this client hasn’t given permission. But if ever need to a firm you’re considering using against the one that did this, contact me and I’ll confirm your suspicion. That’s purely a public service to save you wasting your time and money with these guys.










Posted in 

Entrepreneur, developer, writer, podcaster, teacher, ex-bassist.




April 6th, 2008 at 9:42 am
Wow, that is indeed pretty horrific (and a good candidate for submission on thedailywtf.com). This kind of thing really isn’t limited to just other countries, either – I’ve seen code just as bad developed by “PHP Developers” here in the US who will offer to develop your site for $10 an hour. It’s hard for me to explain to potential clients why my competition can offer development costs 90% lower than mine. :/
April 6th, 2008 at 9:50 am
Brian –
You’re right, in that some US based developers (Western countries in general) do indeed churn out code that bad. I’ve not seen any *that* bad in a long time. And yes, I too struggle with how to explain the value differential. That guy is $10/hour, and I’m $80/hour (I’m not, but you get the idea). I’ve lost out on some contracting gigs recently specifically because I’m ‘too expensive’. No one asks for how long they think the project will take. I can typically rectify problems in a couple hours that would take others days (and have done so many times).
I’m not sure I want actual licensing of software developers, or even certification, but those might go a long way to helping justify a project or hourly rate. I might rather see some system that can certify example code on a scale of some type. ‘Modular’, ‘unit tested’, ‘reusable’, ‘templated’, etc. with ratings for each. “My code is rated ‘above average’ for reusability, for example” might help, as long as people understood the value in reusability.
I dunno – at the end of the day, this whole industry still feels very “wild west”. Some niches – ‘fortune 500′ development, for example – might have more safeguards or recommended measurements in place to help judge quality/value, but the rest of ’software development’ is just up for grabs. The good news is that it’ll keep people who can do ‘cleanup’ in work for a long time. The bad news is that doing cleanup sort of stinks.
April 6th, 2008 at 9:56 am
perhaps someone got paid per line of code
April 6th, 2008 at 12:02 pm
Hmm, I feel a little offended by your post…
I am from Romania (eastern Europe) and my rates are $15/hour for now.
Does this make my code bad? I don’t think so!
The simple answer is that life here is cheaper and I can afford this rate. Of those $15 about $8 are for taxes and the rest are profit. Not much but enough to keep me going at this.
Again, this doesn’t mean that my code is bad. In fact I can compare with anyone in US or elsewhere.
Same goes for any Indian company or programmer. If they can afford a $8/hour rate then good for them. This doesn’t make them bad.
“Cheap” is relative when talking at global level.
The only sane and safe thing your customer should have done was to get references about the company/programmer doing the work for him.
It’s like on Ebay: buying something from a seller with a score of 2 is risky compared with one with a score of 10000, regardless of the price they’re selling the product for.
What I am trying to say is that in programming world price!=quality. Only good references and satisfied customers equals quality.
Dan
April 6th, 2008 at 12:09 pm
Your font size choices are unreadable for me in IE 6. The text size button has no effect either.
April 6th, 2008 at 12:32 pm
I just want to clarify that not every single piece of code that comes from India or South America is a crap. Here in Argentina, lots of companies offer programming services with excelence in mind. They just don’t match those cheap prices you mention, but they are worth the investment.
I know you didn’t mean that, but just to clarify…
April 6th, 2008 at 12:47 pm
Explaining the price difference is equally tough in India, perhaps more so since most people come to the small development companies looking for cost advantages. The only way one could make a profit on the rock bottom rates is to hire the cheapest ‘programmers’ available.
While a lot of good programmers exist, they are sucked into the bigger companies or can be found in those niche markets where higher prices (and therefore higher salaries) are sustainable.
Recently I had to ‘clean up’ code originally written by a German company which was probably as bad as your example. Clients need to look at quality and processes apart from cost, or this can happen anywhere.
April 6th, 2008 at 1:09 pm
I have mixed experiences with outsourcing companies as well. The problem is that because of PHP’s nature, the ‘quality range’ is bigger. For java, you need to have a certain set of programming skills. So Java has a natural barrier of entry. PHP doesn’t have that. The result is that the best PHP programmer is equal to the best Java programmer out there, but the worst Java programmer is still 10 times better than the worst PHP programmer. So the average is lower, and you need to pay more attention to what you hire.
In outsourcing companies, what I have encountered is that a lot of companies that do java, .net etc., then recognize that PHP is booming, and start to sell PHP projects too, without any real PHP expertise. My advise to anyone working with outsourcing is: carefully select the team; demand that you see CV’s, reference projects and talk to a customer who has worked with the company before (on a PHP project).
Regarding the remarks about rates, I see the same problem. our rates are generally higher than a lot of the competition, simply because ‘a lot of the competition’ are script kiddies; if you use software engineers your rates are higher and you’ll have a harder time selling a project (although I must say you also get to do a lot bigger and complexer projects where the higher rates are considered more normal).
April 6th, 2008 at 7:02 pm
This must be an Easter egg! At least it made me laugh out loud. The tough part for customers, especially if they’re not technical at all, is how to assess developer productivity before having them do the whole project.
April 6th, 2008 at 10:31 pm
“To most people code is code”
Unfortunately this is true with most people who seek outsourced freelancers in India. The fact is *You get what you pay for*
You just have to calculate the rates indexed for cost of living in that particular country. We are at times hard pressed to justify why we are $22/hour where as the other guy (a fellow country man) is $10 or lower….
To side step this problem we almost exclusively develop for other developers – makes for a smaller market but much greater peace of mind
April 6th, 2008 at 11:03 pm
Dan:
You’re mostly right, but you need to make sure that the recommendations come from people who are reputable themselves and know how to judge the quality and determine if the projects referenced are similar.
Anyway, it may have come across that I was implying “non-US developer suck”. That wasn’t my intention, cause I think many US developers suck too. Bad developer suck, period. I do think that it’s harder to deal with people who don’t have a command of regional/colloquial English and live 10 time zones away. Additionally, *many* small business people have a hard time explaining what they need in technical terms (which developers need). Also, my own experiences with non-US developers is that they typically will just agree with every thing asked for (and never admit to *not* knowing the answer to something). Rolling all these together and small US businesses trying to offshore development work isn’t usually the bargain they initially think it will be.
I don’t know anything about you Brian. However, the fact that you are reading blogs and engaging with the community tells me you’re a clued-in person, and likely at least a decent if not above-average developer. Where you live and what you charge really isn’t relevant to me if you’re clued-in and a good developer.
April 7th, 2008 at 1:39 am
I read this kind of code daily (for entertainment). You can submit the ‘best’ stuff to http://thedailywtf.com/Contact.aspx to share with a wider community.
BTW the ‘natural barrier of entry’ (language learning curve) doesn’t hinder the efforts of morons much (even in Java).
April 7th, 2008 at 3:26 am
It’s just too easy to write such terrible code in PHP, so every body can code, but it’s hard to find someone can code well.
April 7th, 2008 at 4:22 am
If I read “US/Canada/UK” one more time I’ll run amok. Bad code has nothing to do with the country it’s been produced in. You get what you pay for. If you’re cheap, you won’t get a professional. Hence, you’ll get crappy code. It’s that simple.
April 7th, 2008 at 6:42 am
@RST:
Go run amok then. I’m relaying my experiences. I’m not 100% sure bad code has “nothing” to do with where it’s produced. I think there are some cultural differences between Western countries and non-Western countries that affect how the code is produced. The primary one I’m thinking about has to do with the willingness to ask questions during development and to admit mistakes. Much of the the code (maybe 50-60%) I come across written by US/UK/Canadians has been bad but functional, as in no fatal flaws, but just poorly coded. Most of the code I’ve encountered (say over 80%) that was written by non US/UK/Canadian (Westernish) developers has been demonstrably worse – insecure coding practices, poorly documented code, misunderstood functionality, etc.
Bad code *shouldn’t* have anything to do with where it’s produced, but I’m seeing a correlation between bad code and code not produced in Western countries. That doesn’t mean its a causal relationship, though there may be cultural differences that do make it causal.
April 7th, 2008 at 6:47 am
Oh yeah, I know there’s bad code produced in the US – I did it myself. Back when I was first doing professional coding I was getting billed out at $100-$175/hour, but was producing relative crap. Functional, but poorly documented, poorly structured for reuse, bad security practices, etc. I completely hold my hands up – guilty as charged. That was the beginning of the web, and there was far less understanding of the need for long term maintenance and security than there is today. There were also far less tutorials, free code to copy/paste, etc. That’s not a full excuse, but there was a bit of a feeling like the web might just be a fad, and most of the people I knew threw stuff together quickly.
April 7th, 2008 at 8:00 am
Interesting point you make there. Does that mean that Germans only write code while drinking beer, French don’t write code at all because they are lazy, Italians only write chaotic code, and Eastern Europeans only steal code instead of writing it?
As for the “The primary one I’m thinking about has to do with the willingness to ask questions during development and to admit mistakes.”: Japanese have a history of not being able to cope with mistakes and are very concerned with not losing their faces. But that doesn’t mean that they don’t produce great electronics and fairly good cars.
Anyway, I’m not on a mission here. So let me put my Lederhosen on and get me a beer. I have to write some code.
April 7th, 2008 at 9:51 am
Leaving aside the nationalistic issues for the moment (I don’t think that was really the main focus of Mike’s original post), am I the only one who things $6K is a pretty low bid for a custom e-commerce site? The number of products sold through the site should be irrelevant. If it’s a site where users can purchase stuff, and you are going to completely customize the user experience, there are a lot of issues to deal with. If you’re just hooking up an existing e-commerce solution to a static web site, that’s different of course, but it doesn’t sound like that was the case here. Even in 2008, putting together a good, secure, easy-to-use e-commerce site isn’t trivial, which is why companies like MarketLive exist. (Actually I’d be curious to hear what experiences folks have had with open source in this area, e.g. Magento.
- mps
April 7th, 2008 at 2:35 pm
OMFG… first thing I did with PHP was make a frikin generator for the options and select menu’s :O, somebody slap the programmer with a flip-flop! *sounds nice* ^^
April 7th, 2008 at 3:09 pm
You know how often these examples of outsourcing nightmares actually turn against the first party. Been guilty of that myself. Sending out unfinished, half-empty docs how the work is to be done. And paid the price of time delays because of not paying enough attention..
Two notes:
1) $6k for an ecommerce site? Sounds cheap to me. Or is it just the dollar-euro rate nowadays?
Then there’s ebay, of course.. I mean, how many items (of those 5) they need to sell to make that 6k back? Estimate of one month? two months?
2) The company probably got really lucky on the first job if they provided the same level of tech specs and did similar research on the background of the company abroad. Sometimes it’s a bargain to be lazy and just rely on someone else doing the job, but it hurts to see it backfire as the post headline says..
And yes, The comments about the greate divide between “US/UK/Canadian (Westernish)” and the rest of the world are racist. Then again, a bit of prejudice and stereotyped thinking never killed anyone. (or wait a minute, did they?) Hope this link cheers you up, though.
http://www.phpclasses.org/browse/group/
April 7th, 2008 at 5:53 pm
I have had to clean after an American meth-head. That was more pleasant that when I have had to clean up after outsourced Indian code. I am sure there are exceptions, I just have not seen them yet.
Ukrainian (non-western) oursourced code in my experience has been high quality…
April 7th, 2008 at 5:57 pm
Given that someone can take oscommerce, throw a decent theme on, and have something which can match a client’s basic needs (I need to sell 10 items, for example), $6k *can* seem pretty high. There seems to be no middle ground between “DIY and learn every single aspect of every service and hope that you get everything right” and “100% bespoke 5-6 figures” ecommerce projects.
I’ve heard these war stories before – seen a few too – but I wasn’t prepared for the level of detail this particular client put in relative to the shoddy treatment he got. He forwarded me a 10 page PDF with about 15 screen shots, items circled in red and called out with a list of the wrong behavior. 2 weeks and some emails later of “yes, tomorrow it will be fixed” things are more broken than they were 2 weeks ago. So, yes, some clients want to send out ‘half baked’ specs and expect someone to ‘ do the work for them’. But the 4000 line “option box” to select a state/region from a dropdown has nothing at all to do with the quality of the specs the client originally sent, or the followup correspondance.
As to some of my statements being racist, http://dictionary.reference.com/browse/racist has the following definitions:
1. a belief or doctrine that inherent differences among the various human races determine cultural or individual achievement, usually involving the idea that one’s own race is superior and has the right to rule others.
2. a policy, system of government, etc., based upon or fostering such a doctrine; discrimination.
3. hatred or intolerance of another race or other races.
Perhaps there are other definitions I’m not aware of, but throwing around charges of ‘racism’ shouldn’t be done lightly. I don’t think anywhere I’ve done anything but share my experiences and views based on those experiences. I also don’t think inherent differences between races *determine* culture, but have come to believe that some cultures are not as tolerant of some expressions as others, as I noted above. Perhaps my experiences have *all* been with people working in particular offshoring shops who dictate that people can never express that they have not worked with a technology, and which prevents them from ever asking clarifying questions about a project, and that’s simply been my own bad luck to only have worked with those few dozen people on various projects over the years, and that had I worked with just one ‘real’ outfit, my entire view of offshoring would have been radically altered. That may be – I dunno…
Lastly, it’s hard to do ‘research’ on companies if all they do is lie. “Yes, we’ve done X”. If you haven’t done X, that’s lying. Testimonials from other ‘clients’ may also be suspect (if you’re that cynical). It’s ultimately the client’s fault for believing the lies without doing enough research, but some people tend to take a less cynical view of the world, taking people at their word first.
Whoah, hang on. I just reread Andy’s original paragraph:
You know how often these examples of outsourcing nightmares actually turn against the first party. Been guilty of that myself. Sending out unfinished, half-empty docs how the work is to be done. And paid the price of time delays because of not paying enough attention..
So, the development firm has no responsibility to be professional enough to determine whether or not they have enough information to provide an accurate estimate (both of time and expense)? At what point does the service firm bear any responsibility? This is exactly my point about not asking clarifying questions. A very cynical person would think that this was intentionally done to take money from people half a world away who have little or no recourse. I’m not saying I hold that view, but others might.
April 7th, 2008 at 6:04 pm
@rob – I had mixed experience with Ukranian (well, Eastern European in general) but my brother had a pretty good experience with a remote Romanian developer. Code was good, communication was not bad. Company that was outsourcing had more communication trouble internally than the remote developer did. Likely not that uncommon.
April 7th, 2008 at 8:05 pm
Funnily enough I picked up some code just like this written by some US based developers.
Quality of code has nothing to do with the country you are in rather the amount of training one gets.
April 7th, 2008 at 9:35 pm
if you will use DomDocument, it will be easy. Just push all section in dom, find needed option with right value, chage it and put back on page
April 8th, 2008 at 3:04 am
“So, the development firm has no responsibility to be professional enough… ”
“At what point does the service firm bear any responsibility?”
I see your point. Everyone knows good business relies on mutual trust and understanding each other. Problem comes in when the viewpoints clash in some way. In this case we have clearly a faulty product, delivered late. As huge corporations aren’t often willing to admit their mistakes, smaller shops are just as keen to hold their stand that product is 99% OK and only little late. The responsibility is problematic. And is so ten times more, when the trust is gone.
I guess it boils down to similar rules as in any business. Maybe I’m cynical but it does seem like a used car sale, doesn’t it? The lower the price, the closer one should look at the product?
So yes, I’d shift the balance of responsibility towards the project planner. Not all the way, but some. I think there are so many case studies available presenting the dangers of outsourcing that no intellectual person can really claim having not known the risks when project fails or delays.
About racism: Your definition of racism is the most narrow kind. To some others (including me), racism extends to a whole lot wider range than biological race. Everyday racism is based on gender, location, social status, etc. I think it proves my point that many people have responded the same negative way. I’m not accusing you of being racist intentionally. Just a notion that we all ought to be careful when it comes to judging others, especially larger groups. The original post could have been more subtle without losing the key point of bad experiences with outsourcing, that’s all. Later comments show clearly that this whole debate was not intentional, but some words still really struck a nerve around the world.
It seems to me that the problem here is that although you wanted to emphasize that the opinion is based on *your* experience and purely professional experience (not race, culture, etc.) you kept repeating the rhetoric of “western/eastern” and “US/non-US”, instead of going for more neutral toned “outsourcing”, “off-shoring” or something that way.. So the choice of words (racist to some, maybe not to you?) actually generated negative feelings, no matter how the original point was to draw attention away from the national or ethnic debate. Underlying connotations can really hurt the original message when the reader reacts to words differently than the author.
Just my short analysis of these racism/not-racism thoughts. Awful tricky situations with all these nations and cultures..
April 8th, 2008 at 8:27 am
I’m currently working on a project, a very long term project, and it was one that I inherited from some local US developers. They were charging upwards of $30/hr and while they exhibit a basic knowledge of PHP, they have no business building large scale applications. The application, of which most of it needs to be completely rewritten, redeclares functions 5, 10, and 15 times and has hardcoded page headers and footers just like the sample code here. I’ve slowly been migrating pieces that I touch to a more MVC approach, but it’s tough when you have a mess of spaghetti code. Sometimes I’ve had to write really bad code just to get things working so I didn’t have to spend 20 hours rewriting something to implement a 30 minute fix.
April 8th, 2008 at 8:35 am
@chris – I feel your pain. The Feathers book “Dealing Effectively with Legacy Code” might help give you some ideas for managing the code better. But overall, it just sucks. It’s projects like these where I find myself in favor of professional licensing.
April 8th, 2008 at 1:16 pm
@mgkimsal
I just think of it as the previous “coders” ensuring I have a long relationship with this client. I mean, it’s like they are trying to fund my kid’s college.
June 10th, 2008 at 12:51 am
10 years in business and I have never heard of a project that was outsourced that didn’t have some negative results. I do believe there are good programmers in India, etc. However, programming is not just a work for hire job. Good Programming involved Good planning, implementing business strategies and really getting to the root of the problem that the software will solve. I just haven’t seen a company which can compete with the top notch development teams in the US.
But the reality – when Great programmers are realized in places like India – they are getting work visas and heading to the US – why get $15 and hour when you can make $110k per year here?