December 27, 2006

Code From Hell

I'm still wading through some of the worst code ever written. I keep coming across more nuggets that make me feel like I'm walking through a nightmare, like this gem which shows up nineteen times on one page:
grdDeleted.AllowPaging = dsDeleted.Tables[0].Rows.Count <= 10 ? false : true;
...or nine different ways of pulling from the same DataReader in the same function...

...or broken JavaScript client validation with no follow-up server-side validation...

...or hand-coded time parsing routines that think 18:00 AM is a valid time...

...or repeated code to translate boolean true and false values into the words "Yes" and "No" for storage as strings in the database...

...or Hungarian prefixes that could never have applied in a sane world (cbxStuff is the name of a floating point variable, for example)...

...if I ever think about outsourcing code to the company that created this abomination against maintenance coders, I may just have to shoot someone.

2 comments:

Russell Hunter said...

I know of two reasons off the top of my head why that happens.

I have seen stuff like that by people who got into programming accidentally. They have no training in programming and don’t think things out. They just kick out code knowing that no one will ever look at it again, not even themselves. They end up being inconsistent because they learn stuff along they way. But they don’t take the extra time to clean up old code because they never had to maintain code. It can also happen with programmer just out of collage.

It is also a sign of a programmer who is rushing at the end of a project. The customer won’t make the final payment to the contractor, so they find a simple fix and then just cut and paste code all over the place. It happens quite often on a project with no QA team. Bugs are found way too late and no one has time to work on them.

Good luck. This is just the tip of the iceburg.

Tom said...

Another reason this happens sometimes, and a comment in the post makes me think this is the case - the code was outsourced to a company for cheap who hired a lot of inept people. The code has now been brought back in-house to fix, as should have been done in the first place.