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.

Feb 2013

A CSV is as Good as RAM, Right?

by in CodeSOD on

Matt had heard the argument before. "Scientists can write code just as well as CS majors," his new supervisor at the research laboratory was saying. "As long as the language is mature, Turing-complete, and well-documented."

"Like MATLAB," Matt said.


Inexception

by in CodeSOD on

Exceptions are a great source of stress and suffering. Each exception thrown by our application must be caught handled before the user sees it. Failing to do disturbs the balance of our application. We can use a generic exception handler, but we never can be truly certain we’ve found the true exception. So often the Truth is hidden within an inner exception. It may also be hidden within that exception’s inner exception .

To find truth, how deep must we go?


Internet.toLowerCase

by in CodeSOD on

Parsing HTML is no walk in the park. With the possibility of unclosed tags and mismatched quotation marks on any given page, it’s a veritable minefield of horrible hypertext. However, there are dozens of reliable libraries that a developer could use to do the heavy lifting.

But the heads of the project that Pedro worked on had chosen the worst library they could find.


Fork and Log

by in CodeSOD on

A few years back, Adam C. was brought in to help with some performance problems that appeared while load testing a VXML Platform. The project was already well behind and they couldn't figure out why the system kept falling over under a very slight load. To make matters worse, Adam had absolutely no prior knowledge of the system or its software other than Wikipedia’s definition of what VXML is.

A veteran to these sorts of situations, Adam grabbed a coffee, a donut, and then started picking through the application logs to get a feel for what the system is doing and where something might be going wrong.


Security by Obsqwerty

by in CodeSOD on

Duane was thrilled to be starting his new job. He was already five years into his development career and while he had worked in a number of different areas, he hadn't spend any "professional" time in the one area he was most passionate about: security.

This is not to say that he hadn't spent a lot of his spare time learning as much as he could about various aspects of security. But it is difficult to find a job in the security field when the only mention of 'security' on your resume is in the "Hobbies" section.


Encapsulation in the Hot Seat

by in CodeSOD on

Santosh K. had seen all the emails about the upcoming code audit.


None for All

by in CodeSOD on

Hans used less XML, and now he had two problems.

He was used to the reporting webservices not working. The application had its own special ways of doing security. Often it could be traced back to forgetting the Important Special Code: a http header needed in every request.