CodeSOD: Hitting Your Skill Ceiling

This post was originally published on this site

The Daily WTF

Clia was handed a pile of legacy code and told to upgrade it, but with a very important rule attached: the functionality couldn’t change. Any change could break someone’s workflow, and thus in the upgraded system, even the bugs had to be reproduced.

Unlike most “legacy” code, this wasn’t all that old- it was written in C#. Then again, C# is old enough to drive, so maybe it is old. Regardless, C# has utility methods, like, say, a ceil function. At no point in C#’s history has it lacked this basic functionality.

That, of course, doesn’t stop people from reimplementing it badly.

nToken = (nArea / 12).ToString(12).Tokenize(“”, “,”, sToken); nValue = sToken[0].ToNumber(); nDezimals = (“0,” + sToken[1]).ToNumber(); if (nDezimals > 0.0001m){ nValue = nValue + 1; }

Note, this isn’t a function. This representative snippet is the pattern that was copy/pasted, with modification, anywhere someone needed

To read the full article click on the 'post' link at the top.