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.
« Dec 12

January 2013

Feb 13 »

Reusable Code

2013-01-30
Code reuse is one of the key steps to maintainability. There are many ways a developer might make their code reusable. For example, Steve’s co-worker wrote this block, which generates 1000 log entries:
It was a dark and stormy night. The kind of night envisioned by Mr. Bulwer-Lytton when he penned his infamously bad opening sentence, but the weather was not a deterrent to Craig. Craig faced a task more daunting than mere lightning and rain. He was on the trail of an annoying bug and was determined to track it down come hell or high water (a possibility made more real given the weather).

De-Populate Dates

2013-01-23
"That was call seventeen about the sales logger," said Jeff, "The dates are all mangled. Nothing’s getting logged. We need to escalate."

A Forest of Trees

2013-01-15
Our system was written by neophyte troglodytes who didn't follow standards of any kind. They coded whatever they wanted, however they wanted, whenever they wanted, wherever they wanted. Usually via copy/paste/plagiarize.

InsertSql()

2013-01-09
Data-driven applications need to generate SQL from time to time. Usually, we leverage things like stored procedures or ORM tools to keep our code sane, but from time to time, we might hard code our SQL statements. You sacrifice some flexibility for some transparency into what your code actually does to the database.

Divide and Validate

2013-01-07
In IT, what many developers mistakenly consider to be magic code or evidence of elite (aka "L337") hacker-type abilities actually turns out to just be some cleverly applied math concocted by a developer who chose to think outside of the box.
You know what really gets to me? People who open links too quickly. Haphazardly opening new tabs all over the place...it really grinds my gears.
« Dec 12

January 2013

Feb 13 »