Today, on #rubyonrails, a stubborn developer insisted on storing phone numbers as integers. The rest of the channel tried to persuade him/her that this was a really, really bad idea. Part of the conversation went:
<Cyanshade> you assume that all phones are in the US?
<stubborn_dev_02> yes
<Cyanshade> my phone number is in the form +358 44 123 4567
<stubborn_dev_02> then i’d ban you
(Name has been changed to protect the innocent)
Funny, same topic, phone numbers was discussed by me and friend, just last night.
My buddy: I was in a contract where some engineer types had been doing stuff. They had separated the phone numbers in number groups of three, even though they never used the parts of the number for anything but concatenating them to a full number.
Over-engineered.
This dude you talk about seems to have taken the other route: "The Simplest Thing", but without the Agile corollary "That Could Possibly Work".
Ya, I usually use VARCHAR for phone numbers. I don't care if it's not 100% normalized. But I strip all the \D (non-digits) before storing.
Hm.. I wrote VARCHAR (20) but for some reason (20) got stripped.
It's hard to anticipate every variable that may be relevant to a given field, but this one seems pretty obvious. The coder's response is particularly troubling. Who would knowingly ban people based on their phone number's structure?
I find sites that require no dashes in numbers particularly annoying. Why not just strip them out if you don't want them in the database?