Remy Porter

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

Mar 2013

All the Pieces

by in CodeSOD on

So much bad code arises from the fact that people don’t know that there’s a better way. If a developer doesn’t know about “split” and “join” functions, they might write a cumbersome for loop to manipulate a string. If they don’t know about regexes, they might really overcomplicate some string munging . Or heck, maybe they don’t understand a for loop, and use a while instead.

Maurycy submits this PHP code. It’s hard to really understand how this particular version of the code came into being.


Accounting for Development

by in Feature Articles on

Karen glared across her desk at Tom. “Did you install Visual Studio on your computer?”

“Yes,” Tom replied, unsure why she radiated waves of fury at him.


A Long Running Process

by in CodeSOD on

A process might run for a long time, and it’s important for code to ensure that the long-running process doesn’t crash unexpectedly. Alexander found this block of code, which carefully protects against overflows:

if (_totalSeconds < ulong.MaxValue)
{  
   _totalSeconds += 1;
}  
else
{  
   _totalSeconds = 0;  
}