Remy Porter

Remy escaped the enterprise world and now makes LEDs blink pretty. Editor-in-Chief for TDWTF.

Jan 2017

Overloaded Loop

by in CodeSOD on

Brian found himself digging through some C++ code, trying to figure out a cross-thread synchronization bug. It had something to do with the NetLockWait function, based on his debugging, so he dug into the code.

bool CMyDatastore::NetLockWait(DWORD dwEvent, long nRecord, CMySignal& Signal, DWORD dwTieout)
    bool  retBool;
    long  value;
    DWORD reason;
    DWORD currentAttach;
    CTimerElapsed timeout;


    retBool = false;

    while (timeout)
        if (::WaitForSingleObject(Signal.GetEvent(), timeout) != WAIT_OBJECT_0)

        Signal.Pop(reason, value);

        if (reason == dwEvent && value == nRecord)
            retBool = true;
    return (retBool);

Checked Numbers

by in CodeSOD on

Dealing with types in dynamically-typed languages is always a challenge. Given a variable, does it hold a string? A number? An object? Without inspecting it, you have no idea!

Thus, most of these languages have methods for inspecting variables, where you can ask questions like, “is this a number?” and then decide where to go from there. This can make validating your inputs a bit more difficult.

The Mailing List

by in Best of Email on

The Best of Email feature is not one that gets a lot of traffic these days, but this particular submission couldn’t fit anywhere else. It started when Justus got a ticket: “customer spam filters are blocking our emails”. How on earth was he going to fix customer spam filters? He almost replied as much to the ticket, when he noticed that the end user had helpfully attached a sample email.

This was the “to” line… and I present it here in its entirety, exactly as supplied by Justus. I apologize to mobile users in advance:

Unstructured Data

by in Feature Articles on

Alex T had hit the ceiling with his current team, in terms of career advancement. He was ready to be promoted to a senior position, but there simply wasn’t room where he was- they were top-heavy as it was, and there were whispers among management of needing to make some cuts from that team. So Alex started looking for other openings.

There was another team at his company which had just lost all of its senior developers to other teams. Alex knew that was a bad sign, but in general, climbing the career ladder was a one-way street. Once he had a senior position, even if it was terrible, he could transfer to another team in a few months, keeping his senior title and salary.

Popping a Plister

by in CodeSOD on

We live in a brave new world. Microsoft, over the past few years has emphasized, more and more, a cross-platform, open-source approach. So, for example, if you were developing something in .NET today, it’s not unreasonable that you might want to parse a PList file- the OSX/NextStep/GNUStep configuration file format.

But let’s rewind, oh, say, five years. An Anonymous reader found a third-party library in their .NET application. It never passed through any review or acquisition process- it was simply dropped in by another developer. Despite being a .NET library, it uses PLists as its configuration format- despite .NET offering a perfectly good in-built format. Of course, this C# code isn’t what we’d call good code, and thus one is left with an impression that someone hastily ported an Objective-C library without really thinking about what they were doing.

Sponsor Announcement: Hired

by in Announcements on

There are certain tropes that show up in our articles, and judging from our comments section, our readers are well aware of them. For example, if a manager in a story says, “You’re going to love working with $X, they’re very smart,” it’s a pretty clear sign that the character in question is not very smart, and is almost certainly sure to be TRWTF in the story.

Part of this is narrative convenience- we try and keep our articles “coffee-break length”, and dropping a few obvious signals in there helps keep it concise. Most of it, however, really boils down to the fact that reality is full of certain patterns. The world is full of people who aren’t half as smart as they think they are. There are legions of PHBs ready to micromanage even if they haven’t a clue what they’re doing. And there are a lot of employers that can make a terrible job sound really great for the duration of the interview process.

Eventful Timing

by in CodeSOD on

I once built a system with the job of tracking various laboratory instruments, and sending out notifications when they needed to be calibrated. The rules for when different instruments triggered notifications, and when notifications should be sent, and so on, were very complicated.

An Anonymous reader has a similar problem. They’re tracking “Events”- like seminars and conferences. These multi-day events often have an end date, but some of them are actually open ended events. They need to, given an event, be able to tell you how much it costs. And our Anonymous reader’s co-worker came up with this solution to that problem:

Extended Conditions

by in CodeSOD on

Every programming language embodies in it a philosophy about how problems should be solved. C reduces all problems to manipulations of memory addresses. Java turns every problem into a set of interacting objects. JavaScript summons Shub-Niggurath, the black goat of the woods with a thousand young, to eat the eyes of developers.

Just following the logic of a language can send you a long way to getting good results. Popular languages were designed by smart people, who work through many of the problems you might encounter when building a program with their tools. That doesn’t mean that you can’t take things a bit too far and misapply that philosophy, though.


by in CodeSOD on

In the early 2000s, it was a time of darkness, a world of fear, it was the age of XML. As someone who was just entering the industry at the time, you couldn’t type three lines of code without a PHB asking, “Have you considered using XML for this?” Since this was 2002, “this” was likely trying to find a way to emulate the marquee tag in JavaScript, the answer was usually, “No,” at which point you’d be reminded that we should be using XML for everything, so throw it out and start over in XML.

One of the key selling points of the grand power of XML was the idea of schemas. These magical little files allowed you to use XML to specify the structure of some other XML, and then validate various XML documents against that schema. Combined with the ability to use namespaces, this was truly the One Format to Rule Them All™.

Do You Think This is a Game?

by in CodeSOD on

We’ve passed Christmas and made our way through a Steam sale with our wallets mostly intact, and now most of us have a pile of games that we’ll probably never actually play.

Game programming is hard. Setting aside the “cultural” problems in the industry- endless crunches, compensation tied to review scores, conflicts between publishers and studios, and a veneer of glamour over unglamorous work- the actual work of developing a game is a hard job.