Remy Porter

Computers were a mistake, which is why I'm trying to shoot them into space. Editor-in-Chief for TDWTF.

Jan 2014

Income

by in CodeSOD on

While checking the local news, Sarat discovered an “income ranker” widget on a news site. He put in his monthly income, and discovered that he was in the top 0.08% richest households in India. Surprised to discover that he was a gazillionaire, Sarat took a look at the JavaScript code which ran the widget.

The function definition started with function submitmyform(), which already looked pretty bad. Sarat looked for the block responsible for calculating the result, and found this charming anti-pattern:


GHOST Busted

by in Feature Articles on

Some developers look at a problem and say, “Let’s solve it. With code!” Then there are other developers, who say, “This specific problem is a subset of a general class of problem, which, if we solve the general class, will automatically solve the specific class.” The best programmers know when it’s time to keep it simple, and when they really should shoot for the stars.

Chris worked for a startup run by former academics. They wanted to shoot for the stars, some black holes, and maybe, if there was budget left over, the primordial galaxies that formed after the Big Bang. They had an idea for a product which would… well, Chris had no idea what it did.

The vision was codenamed SPRIT. Walter, the wizard behind it, couldn’t explain its purpose in terms anyone else understood. The only thing he could explain was that SPIRIT needed to be implemented in the in-house language, GHOST. “It’s a joke,” Walter explained once, “It stands for ‘Generic Hybrid Script for Transactional Objects’. The acronym is out of order because GHOST is all about parallel processing. It’s funny.”


Dropped Catch

by in CodeSOD on

Alex still has some VB6 code lurking in his environment. Like too much VB6 code, it’s littered with On Error Resume Next statements, which allow lazy programmers to simply ignore errors. It’s an easy way to make crash-proof applications in VB6.

One of their database programmers decided to compete with that anti-pattern . This programmer wrote a huge pile of database triggers which looked like this:


Productive Testing

by in Representative Line on

Unit tests have many uses. Primarily, they’re the canary in the coal mine of our code, and alert us when changes are about to go horribly wrong. When Niels’s team saw a recent change broke their unit test, they instantly knew how to fix it.

In the DONE column of the kanban board, a post it reads 'Remove Failing Test'