News for hackers. Stuff that matters.
Re:The Narcissism of Small Code Differences (2008) by 3pt14159 on Monday November 11, 2013 @08:01AM (#6711363)
If you want to treat a number like a string, why not just treat it like a string? When people enter zip codes online they enter 07045, so why not just store that? Even forget about other countries like Canada it seems like the best way...
Re:The Narcissism of Small Code Differences (2008) by dagw on Monday November 11, 2013 @09:02AM (#6711587)
There are lots of way to accidentally lose a leading zero along the way. For a quick and realistic example make a csv file the looks like:

   01234,Hello
import it into Excel, edit something and export it as csv again. Unless you pay careful attention to what you're doing, you've just lost your leading zero.
Re:The Narcissism of Small Code Differences (2008) by z0r on Monday November 11, 2013 @08:36AM (#6711481)
Agreed - if you're going to validate anything at all, define a new type and don't hide the constraints checking within a secret unit testing lair. I hope I would be agnostic about the code here though, there is no point rewriting poorly conceived stringly typed code - that's a symptom that such efforts would be part of a losing battle
Re:The Narcissism of Small Code Differences (2008) by mtsmithhn on Monday November 11, 2013 @08:38AM (#6711487)
The code was for handling zipcodes from a CSV file so we don't really know where the data came from.