Recent Articles

Apr 2012

Self Documenting

by in CodeSOD on

"A little while back, someone introduced the concept of 'self-documenting' code to our team," writes Ryan L. "It was certainly a step forward, but it's somehow taken us two steps backwards. Consider, for example, the following code from an MVC controller."

if (TheFormIsInvalid()) return View("Index", form);

... snip ...

private bool TheFormIsInvalid()
{
    return ModelState.IsValid == false;
}

Out of Service

by in Error'd on

"I came across this 'digital' sign in NY Penn Station," Dan wrote, "for some reason, it makes me think of Mitch Hedberg."


Classic WTF: Behavioral Deficiencies

by in Feature Articles on

I'm on vacation this week and am a bit behind on all things TDWTF; so, here's Behavioral Deficiencies. It's a classic that was originally published on February 28, 2008.


Shawn O. was not used to bright lights, smiling faces, or greetings like “hi Shawn, how are you today?” In fact, just about anything that wasn’t specifically intended to bring pain and misery to all had become foreign to him. It was simply par for the course. Shawn, after all, was an Oracle DBA. And not just any Oracle DBA, but one who sat on the company’s Database Code Review Council.


The Enterprise User Agent

by in CodeSOD on

"When the job ad specified that an 'enterprise' Senior Java Developer was needed, I knew I'd be in a treat for some enterprisey goodness," writes Chris B, "but what I didn't expect was the User Agent Detection Generation Framework. Here's what the API for this framework looks like."


A Minor Error

by in Error'd on

"I was a bit worried when I received an alert from the bank telling me that my balance went bellow $25," Mike, "I called the bank to see what was going on, and they chalked it up to a 'minor' error. I'd sure like to know what a major one is..."


Simple Date Validation

by in Representative Line on

Simple Date Validation "I'm very fortunate that my new job is at a cool company working with cool coworkers on cool projects," writes Dave via the Submit to WTF Visual Studio Plug-in.

"Of course, it wasn't always like this. Many years back, WTF Joe (as we now call him) was a key contributor to our codebase and always worked hard to find the hardest way to do the simplest things. Like date validation.


The Core Launcher

by in Feature Articles on

“You R haccking files on my computer~!!!” Charles Carmichael read in a newly-submitted support ticket, “this is illigle and I will sue your whoal compiny. But first I will tell every1 nevar to buy youre stupid game agin.”

The bizarre spelling and vague threats were par for the course. After all, when you market and sell a game to the general public, you can expect a certain percentage of bizarre and vague customer communications. When that game is a popular MMPORG (no, not that one), that percentage tends to hover around the majority.


get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

by in CodeSOD on

"As part of my new role for a software development firm," writes David Mayer, "I was assigned to sift through some code looking for bugs in the dictionary and spellchecking system. That's how I came across a function called get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function."

"One definition of the word perimeter is 'the length of a line', which seems ironic given that all the variables used are obscene in length. Incidentally, one such perimeter defines 'pass-a-number' which indicates to the function that the second perimeter will be a number. But given this function converts numbers to words, I fail to see why you would 'pass-a-letter'. "


Complex Drying

by in Error'd on

"I liked the trial version of Marble Blast Ultra," wrote TJ, "but after some deliberation, I decided $53,687,091.18 worth of MS points was a little steep for the full version."


Securely Random Strings

by in CodeSOD on

"Working through a pretty ugly project, I came across this C# beauty," Matt B writes, "at first, I was unsure of what it did. I was utterly perplexed until I took a second look at the function name. "

"It turns out, it produces a random string of letters. It was used to create a random ID for some URLs. Apparently, this developer was too proud for base 64 encoding, MD5, or some good old ASCII conversion."


Difficult Personality

by in Feature Articles on

It was Steve's first week on the job, and he had plenty of questions about the code base and the new features he was supposed to implement. He muddled through for most of the week, but Friday morning he hit a brick wall and needed to talk to Bill, the architect.

"Can I meet with you for like an hour to go over things?" Steve asked.


EvalToInteger, 'gumdrops', and More

by in Coded Smorgasbord on

"I recently found this while going over some code in a Util library used by my project," Ian writes, "clearly, this method makes sure the job gets done."

public static int EvalToInteger(string statement) {
     string s = EvalToString(statement);
     return int.Parse(s.ToString());
}

Really Secure WPA

by in Error'd on

"I appreciate that TeamViewer gives me an option to update," writes Chris, "it's just too bad that option is 'No'."


Missing Files, The Amazing Print Driver, and More Support Stories

by in Feature Articles on

Women ARE from Moires! (from Shane)
As the net admin for a small municipality, I don't get to do front-line support much anymore, but a few years ago, I fielded one that was rather bizarre. A user called complaining about distortion on her CRT... it looked all... "melted". Their office was just down the hall so I went over and sure enough, the display was badly mangled. Degaussing didn't help. Then I noticed a foot-long fluorescent light affixed to the bottom of the metal shelf above the monitor.

"Has that always been there?" I asked her. "Yes, she replied, but I just moved the computer here, it used to be over there..."


Authenticate or Math

by in CodeSOD on

"I was recently assigned to work on a project that had been abandoned by its developer," wrote George Z. "After I checked-out the code for the first time, I started sifting through hundreds of lines of bad syntax, and bad practices."

"After a good hour or two looking I came across this little gem."


Roman Enumeration

by in CodeSOD on

"At my company, the powers-that-be determined that, because we rejected a lot of job candidates, my group was ineffective at hiring new employees,"Kendall writes, "thus, the responsibility of hiring new developers was shifted to a group much more proficient at hiring: human resources."

"That has been going about as well as you might expect, and to make a long story short, we were told to handle any 'knowledge gaps' with training. And thus, one of the very first training jobs I give to new employees is to develop a method that translates Roman Numbers to Decimal Numbers. Most struggle with the challenge, but one new hire actually managed to solve the problem: