Article 6J1GE CodeSOD: Pretty POed

CodeSOD: Pretty POed

by
Remy Porter
from The Daily WTF on (#6J1GE)

"QPirate" was debugging an issue with purchase order version information. The format was supposed to be "Revision#.Version#", essentially "major" and "minor" versions for the various steps as the purchase order wormed its way through the company's incredibly complicated purchasing process.

Unfortunately, that isn't what was happening. Many numbers behaved in unexpected ways when they were versioned too many times. QPirate dug in, and found this:

double PRVN = Convert.ToDouble(dr.PoRevNumber) + (Convert.ToDouble(dr.POVerNumber) / 10);

In a reverse of the usual problem of stringly typed information, here we try and represent what should be strings as doubles, and there lies the root of our problem. POVerNumber gets divided by 10, which if you only have 9 versions, that's fine- but as soon as you have ten or more, your POVerNumber starts getting added to your PoRevNumber.

The fields were actually strings to begin with, which adds insult to injury. They had to convert them to doubles to do this arithmetically challenged solution to version numbers, instead of just doing some string concatenation.

For bonus points, I really enjoy the inconsistent capitalization of PO.

buildmaster-icon.png [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
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