Article 42E0C CodeSOD: Hitting Your Skill Ceiling

CodeSOD: Hitting Your Skill Ceiling

by
Remy Porter
from The Daily WTF on (#42E0C)

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 the ceiling of a value. Clia dutifully replicated its behavior, unchanged.

raygun50.png [Advertisement] Forget logs. Next time you're struggling to replicate error, crash and performance issues in your apps - Think Raygun! Installs in minutes. Learn more. TheDailyWtf?d=yIl2AUoC8zAb0Xx9ZrS1aU
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments