I was discussing various stuff on IRC and one of my friends mentioned this great article, written by his company, discussing various "example programs" submitted to his company as part of a resume.
http://i4031.net/article/2003/08/badcode.pH.
Some choice examples from the article:
From some C code:
...
* Disclaimer: This source code has NOT been compiled.
* I would estimate a couple more hours of development to
* eliminate any typos and other compile time errors.
* Then the fun starts.
...
*/
The ever popular perl version of arrays:
my ($f0, $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $f9);
my ($f10, $f11, $f12, $f13, $f14, $f15, $f16, $f17, $f18, $f19);
my ($f20);
...
for ($idx = 0; $idx < $NUMBER_OF_ITEMS; $idx++) {
$name = "mn" . $idx;
$refval = eval "\$f". $idx;
...
}
And my favorite:
$ref_urlsWithoutQueryStringTranslatedPassOne =
translatePassOneWithoutQueryStringURLs($self->{urlsTrainingNonQueryGo
+od}, $self->{CONSTANTS});
$ref_urlsWithoutQueryStringTranslatedPassOnePostGrouping =
groupWithoutQueryStringURLsAfterPassOneTranslation($ref_urlsWithoutQu
+eryStringTranslatedPassOne,
$self->{CONSTANTS});
So what kind of terrible code have you seen or written in your time as programmers?
Update:
I just want to make this absolutely clear. This article is not, in any way written by a company. Or a business. Or any sort of inanimate object. It if in fact, written by a human. I think. At least vaguely humanish. Kind of. Mostly.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.