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 2011

Representative Property: MaxRetry

by in CodeSOD on

"I’m a big fan of the Representative Line series," Rich writes, "it tells so much about an application in so little. While there are plenty of representative lines I could show about our application, I thought I’d show something else: a representative property."

"It’s a pattern we’ve termed the Bait & Switch Property."


Encrypted XML

by in CodeSOD on

The vendor of a certain, seven-figure software package that Thijs B's company relied on just released a new version that was no longer end-user configurable. Well, technically, it was... it just required the purchase of a $100,000 "configuration tool" instead of simply editing an XML file. While dropping $100K isn't too bad for most companies in the seven-figure software market, this particular company was frugal and thought it'd be worth investing some time before dropping a giant wad of cash. So, it was up to Thijs to see if the product was still configurable without the new tool.

Thijs opened up the familiar fieldset.xml file, but instead of finding a convoluted — but human-readable — mess of XML, he found this:


The Shapes

by in CodeSOD on

"Despite working at my company for a year and a half," Carlos Barbosa writes, "I'm still amazed at what I find in production."

"Most of it is either impressively bad, or just so damn ugly that even its creator would avert his eyes. But sometimes, I find just plain weird. This was one of those times."


The Legacy Handover

by in CodeSOD on

It was supposed to be a simple handover. One legacy application that was about to be retired. Paul smiled and took full responsibility.

It wasn't the complete absence of any documentation that broke him. Nor the extended hours trying to get it to build and run on another PC while the PHB bombarded him with messages from the airport on his way to a week’s holiday. The odd C++ inheritance wasn't a problem, nor the home brewed string class. The massive data allocation did cause a few raised eyebrows but thankfully it didn't leak badly enough to fix just yet. After all, it was going to be retired just as soon as Paul could get it running on anybody else's machine and it only crashed once an hour. The custom logging API, while not unusual, was no worse than anything Paul had met before.


The Pesky "e"

by in CodeSOD on

"As a general rule of thumb," writes Newman, "we ignore all build warnings. After all, the code complies... so why bother worrying about warnings?"

"We also ignore errors and exceptions. After all, you can just write On Error Resume Next or use Try/Catch blocks to make them go away."