Cerebral Flatulence

Remy escaped the enterprise world and now works as a consultant. Editor-in-Chief for TDWTF.

There’s plenty of bad code that makes you ask, “what were they thinking?” There’s a whole bunch of code we get, however, that doesn’t even raise that question- the programmer responsible simply wasn’t thinking. Today, let’s examine a few “programmer brain-farts”. We turn our attention first, to Jim C.

While reviewing some unit tests, he found this line:

if (!succeeded) {
SmartAssert::IsTrue(succeeded, messageStr);
}

This, obviously, confirms that succeeded is false, and the asserts that succeeded shouldn’t be false. Perhaps not so smart an assert. Jim ran blame to find the party responsible, but as it turned out- he had written this code six months earlier.

Oh, to live in a world where we are the only source of our own pain. Jason is not so lucky. It was the eve of a major release, and there was a bug. Certain date values were being miscalculated. What could possibly be the cause?

Well, after a frantic investigation, he found a fellow developer had done this:

What is supposed to be calculating out one hour prior was actually calculating out 1000 times that much. While they discovered this bug right before a release, the code had been in production for months.

Meanwhile, Dave was hunting through some code, trying to understand some of the output. Eventually, he traced the problem to a function called generateUUID.