Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Jul 2012

Denumerating the DayOfWeekEnum

by in CodeSOD on

"When I first found this custom 'enum'," writes Garrett Hopp," I had assumed that my predecessor had re-implemented the DayOfWeek Enumeration. I suppose that wouldn't be that big of a WTF as discovering the built-in DayOfWeek does involve using a search engine... which many developers seem to struggle with."

"But upon closer inspection, I realized it's a bit more than that, and is a really clever way to write (int) DateTime.Now.DayOfWeek. After all, that'd just be lazy."


Take a Walk on the Client Side

by in CodeSOD on

"Performance matters," Bob was told on his first day. The company prided itself on using the latest, cutting-edge techniques, and emphasized the use of client-side code to keep the application responsive.

One day, while tracking down a JavaScript error, he got a very good picture of how their client-side code actually worked:


The MySQL Wrapper Wrapper

by in CodeSOD on

Hey Pittsburgh Readers – I'll be in town this weekend, so who's up for grabbing a couple drinks tomorrow, Friday (July 13) Night at Market Square? Mark, Remy, and I will be there -- just drop me a line and we'll catch up. Oh, and I'll make sure to bring a TDWTF Mug for you if you’d like one (just let me know).


"A fairly ambitious project at work necessitated some extra, temporary help," wrote Richard, "and that meant it was time to bring on another contractor. After interviewing a number of different candidates, I found one that seemed to fit the bill. He had the necessary PHP skills, knowledge, and experience – and most importantly, he was will willing to work at the rate my company was willing to pay."


Tale of the Cryptic Encoding

by in CodeSOD on

Lee S. nodded gently as she re-read the message-board post.

Someone named Robbie had created a posting asking for assistance in resolving a problem with a simple Visual Basic .NET console application. It was used to retrieve and process product registrations and credit card transactions via the Internet for a piece of niche shareware.


Unconditionally Useless

by in CodeSOD on

"The code that I maintain was originally developed when OS/2 Warp was considered new," Danielle writes. "One of the biggest challenges I have is that the original coders are long gone, and the comments they left behind aren't exactly useful."

"They were firm believers in commenting not only the beginning of a conditional if-block, but also the end block. In theory, that can be helpful... but in practice, not so much."