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.

Oct 2009

"PHP has an eval function like perl"

by in CodeSOD on

One of the sysadmins at Stuart Caie's company — Jim, as we'll call him — wanted to scratch his itch. Because he spent a whole lot of time logging into different systems just to gather operational data, he figured that a simple web application could automate the data collection process. "This way," he persuadingly said to management, "I can be much more efficient when doing my job."

The brass agreed and allowed him to dedicate some time to building a monitoring application. Jim was excited and ready to overcome his first obstacle: he didn't know anything about programming. Fortunately, Learn Perl in 21 Days and Learn PHP in 21 Days showed him the way and, in no time, Jim had a nice little web app built. His co-workers congratulated him on it and asked him to build in some more features. Management was also pleased with the tool and allowed him to spend some more time in development. And so Jim kept adding to it and adding to it. Again and again.


Is the Mainframe On?

by in CodeSOD on

The asset management application used Alex R.'s company isn't exactly bad, but sometimes it can be a little bit of a pain.

For example, some time ago, some deveoper implemented a feature that would check if the mainframe was up and running. This was done by simply querying a column in some database table. But shortly thereafter, users noticed that there was a brief pause after entering their password. Nothing earth shattering, it was just annoying.


Ask Rumen

by in CodeSOD on

"We recently inherited an ancient ASP.NET application," Misho D writes, "well, ancient as in .NET. The development started around 2002 and the maintenance never seems to end." "Given that it was probably the original team's first .NET (or one of the first) .NET applications, the WTF-to-line ratio is pretty high. But there's one recurring theme throughout the code that is baffling: some guy named Rumen. His name and comments are all throughout the code."

protected PostControlMode GetMode()
    // this is set from code because of 
    // mehtod call flow - binding is before loading 
    // and problem appear - ask Rumen for details
    return PostControlMode.Blurb;
}

Encryption Misinformation

by in CodeSOD on

Ages ago, one of the business units at the corporation that Rick P. works at contracted a 3rd party vendor (in truth it was some guy in the UK) to write an inventory management system.  It was written in VB6 and talked to an Access database in the back end and it worked.

Skip ahead to recently when an edict has come down from the powers-that-be declared that any VB6 apps should be brought up to date in VB.NET.  The 3rd party dev was happy to make the updates and rollout the now conforming application.  Unfortunately, the availability and quality of support had gone downhill as of late and in order to save on costs, the application's source code was recalled to be maintained in-house.


Walter Logged

by in CodeSOD on

"You've gotta help us out," Thomas's client pleaded, "you know, work some of your Java magic or something. We've tried everything: double the RAM, upgrade the pipe, and add in more servers. But nothing seems to help: it's still slow as molasses."

Of course, had they listened to Thomas in the first place and not had Walter, their in-house developer, architect the transaction-processing system, they wouldn't be in this mess in the first place. As tempted as he was to say "I told you so," Thomas simply agreed to come in the next day and see what he could do.


The Clever Coder

by in CodeSOD on

Jan's coworker had come to be known around the office as The Clever Coder. Not quite the clever we've come to expect on The Daily WTF, but more the unfunny-uncle-who-thinks-he's-funny sort of clever.

His code wasn't all that great, and his cleverness wasn't all that... well, clever. One of his more frequently used methods was the following.


RegExp From Down Under

by in CodeSOD on

"The company I work for sells vacation packages for Australia," writes Nathan, "and for whatever reason, they're marketed under different two different brands — redacted-travel.com.au and redacted-travel.com — depending on whether you live Down Under or somewhere else in the world."

Nathan continues, "one of the requirements for the international website (redacted-travel.com) is to disallow people from within Australia and New Zealand to make bookings. But the way this is done from the front end... well, it's a real gem."