Alex Papadimoulis

Founder, The Daily WTF

Jun 2010

Avoiding the Exception

by in CodeSOD on

"I found this interesting tidbit while making some changes to a .NET application," Tim Kowalski writes.

"Although the original developer claims to 'spend 9/10ths on the rule and not the exception', I would argue it's more like 5/10ths on the excuse, 4/10ths on the rule, and 1/10th avoiding the exception."


"True" and True

by in CodeSOD on

"We have an old codebase where strings are used as a swiss army knife," writes Jimmi Hested, "almost everything that goes in or out of a function is ends with a .ToString(), even it's already a string... and sometimes even if it already ends with .ToString()."

"Here is a bit of code from our web front-end. Not only is there a try/catch (just to make sure everything works), but the original developer felt a string was way better than a bool."


Critically Conditioned

by in Feature Articles on

brykmantra @ FlickrBeep. .... Beep. .... Beep. .... Peter stared aimlessly at the heart monitor above his wife’s hospital bed, watching the green lines zig... then zag. Then zig... then zag. It was calmingly hypnotic, especially after five long hours of sitting by her side in the cardiac unit, waiting around for test results.

Suddenly, the steady pace of beeps increased and Peter snapped out of his daze. Looking around, he spotted the culprit: the doctor was in route and was making his way towards the bed. “I just wanted to let you know that we’re still waiting on the final enzyme analysis,” the doctor said as he flipped through papers on his clipboard, “the first tests were… hmm… inconclusive. So, it shouldn’t be much longer.”


1's and 0's

by in CodeSOD on

Consider "0010000000100000". It's a string filled with nothing but "1" and "0" characters. Now, unless such a string is part of some classroom assignment where the goal is to programmatically convert Based 2 to Base 10 — or, perhaps, existing in some highly-limited and/or perverted language like MUMPS — there is never a good reason for it to exist in a program.

Because there are so many more appropriate data types — a boolean array, an integer bitmask, or even an integer array, just to name a few — a "boolean string" is a canary in the coalmine. If it's in an application's codebase, then chances are, there's something seriously wrong with that code. If, perchance, such a string is found in a VARCHAR column in some database, then something isn't just seriously wrong, the application is nothing short of an epic disaster.


A Gracious Grace Period

by in Error'd on

"Some applications offer you a grace period before your password expires," Michel van Zoest wrote, "I think I'll leave instructions in my will to have one of my great-great-great-great-great-great-great-grandchildren change the password for my database in about 50539024859478222 years. If we survive the death of our sun, that is."


The Interupting Rebutter, The Final Word, and The Jury Rig

by in Tales from the Interview on

All three of today's Tales from the Interview are from R Huckster.


The Interupting Rebutter
The job sounded right up my alley: it was in a field that I was experienced in, offered a laid-back environment, and employed a young and hip workforce. After passing a few programming brainteasers and describing my experience in the field, I thought I was a star candidate. That is, until the interviewer asked me specific details about my previous job.


IsListconntSmalleThaOne

by in CodeSOD on

If Peter Moberg were to give a single criticism of his colleague's work, it would be that it represents a complete and total misunderstanding of the principles of software development.

Criticisms #2 and #3 would probably center around typos/misspellings and completely superfluous code. Today's example illustrates all three.


Well-Formed XML

by in CodeSOD on

Diego was excited. A vendor — one that, for the record, he had no choice but to work with — finally put together a web service. This was big news because it meant that Diego would no longer have to battle proprietary TCP protocols to get data extracts; he could use a simple, well-established protocol to download the data he needed.

When the vendor delivered the service documentation, however, Diego was a little disappointed. It was a little more... simple... than he had imagined.


The Long Walk

by in Error'd on

"I searched for a route to walk from Southampton to Edinburgh(UK)."Albert writes," but for some reason, Google Maps wants me to slip over the border into France, back to UK, back to France, then again to UK!"


The Quotient ID

by in Representative Line on

To say that the codebase at Andy’s client is sub-optimal would be generous. It’s a kludge on top of a kludge that was cobbled together by countless developers over many years. And as with many large and unwieldy information systems, distilling this beast into an understandable form is a challenge superseded only by the actual maintenance of the code.

As such, a brief snippet — a representative line if you will — offers perhaps our best glimpse into the heart of the system. And what a better place to look than its most tragic part: the database. Following is a portion of a line (a SELECT statement) that illustrates a pattern used over and over within the code.


Liberal Leave

by in Feature Articles on

It’s hard to believe that it’s almost summer. Actually, that’s not true; summer basically comes at the same time every year, and it’s slowly transitioned to through a period known as “spring.” But what is hard to believe is that just three short months ago, we experienced the most brutal winter ever.

Dubbed The Snowpocalypse and Snowmaggedon, the 2010 blizzards dumped an obscene amount of snow on the Washington DC area. So much that even the monstrous machines dedicated to clearing said snow were no match. “Due to blizzard conditions and near-zero visibility on the roadways,” emergency services announced after one storm, “to protect the safety of city employees and residents, all snowplowing operations have been temporarily suspended until weather conditions improve.” Now that’s some serious snow.