
Falsehoods Programmers Believe About Phone Numbers - prostoalex
https://github.com/googlei18n/libphonenumber/blob/master/FALSEHOODS.md
======
CapitalistCartr
This is much like Patrick's "Falsehoods Programmers Believe About Names".

[http://www.kalzumeus.com/2010/06/17/falsehoods-
programmers-b...](http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-
believe-about-names/)

~~~
greenyoda
Also:

Falsehoods programmers believe about time:

[http://infiniteundo.com/post/25326999628/falsehoods-
programm...](http://infiniteundo.com/post/25326999628/falsehoods-programmers-
believe-about-time)

More falsehoods programmers believe about time:

[http://infiniteundo.com/post/25509354022/more-falsehoods-
pro...](http://infiniteundo.com/post/25509354022/more-falsehoods-programmers-
believe-about-time)

Falsehoods programmers believe about geography:

[http://wiesmann.codiferes.net/wordpress/?p=15187](http://wiesmann.codiferes.net/wordpress/?p=15187)

Falsehoods programmers believe about addresses:

[https://www.mjt.me.uk/posts/falsehoods-programmers-
believe-a...](https://www.mjt.me.uk/posts/falsehoods-programmers-believe-
about-addresses/)

~~~
jameslk
Nice! I wish I had known about these articles before. I just created a
repository to keep track of them: [https://github.com/jameslk/awesome-
falsehoods](https://github.com/jameslk/awesome-falsehoods)

~~~
Rafert
Shouldn't that be 'A curated list of awesome falsehoods'? ;)

~~~
jameslk
Indeed :) I updated it and made it a bit more specific: "A curated list of
awesome falsehoods programmers believe."

------
ryandrake
I've always loved the "Falsehoods Programmers Believe About Xxxx" articles.
There's always that junior developer who says, "We need a Xxxx handler! That's
easy, I'll write it myself in an hour!" (where Xxxx is either a time, address,
name, etc., something with a huge number of tricky potential edge cases). You
can just watch the bugs jump into the program as he types. Then you get to
testing:

Me: Try this test.

Dev: Oh, didn't think about that one, let's add that case.

Me: How about this?

Dev: What? OK OK, let's support that too.

Me: And this one...?

Dev: Wait, what? How is that even...?

The code is about 200 lines now, and we've blown the afternoon, and it still
doesn't properly handle Xxxx, so I'll forward him the "Falsehoods Programmers
Believe About Xxxx" article.

Dev: Oh crap, maybe I should have looked for a tried and true library that
handles Xxxx....

Me: Yes, grasshopper...

------
aexaey
Not exactly a falsehood, but certainly a quirk:

In general, in Europe "0" is national dialing prefix, leading to numbers
written in the format of:

+44(0)870123456, meaning dial 0870123456 from within the UK, and +44870123456
internationally to reach the same number (i.e. "0" goes away in international
format).

However in Italy, leading "0" in the national dialing format is an integral
part of the phone number itself (only for non-mobile numbers); for example:

(+39)051234567 meaning 051234567 when dialing from within IT, and +39051234567
internationally (i.e. "0" stays in international format).

EDIT: Mobile numbers in Italy don't have leading "0", and could only be dialed
in full/international format either within the country, or internationally.

~~~
Symbiote
I think the +4412345... form, or +39012345... work in all situations. But,
outside small countries many people will be unfamiliar with a number in this
format.

~~~
rwmj
Additionally some people believe that dialing a +XX, or even regional number
will cost more even if they are in the same country/region. Which, at least in
the UK, at least with common service providers, is _not_ true.

------
j2kun
0\. Every internet user has a phone number they can be reached at.

~~~
david-given
This is my pet hate. There are too many places which require a phone number
and won't take no for an answer. Some of them you can lie to, entering
something that's obviously invalid like 0, but others do rigourous validation
and simply won't let you enter something that's not a phone number (Google
Play is an offender here). I usually end up entering 012345678, but that's
actually a valid UK number, and I don't like doing that. But you have to
wonder about any online form which requires you to lie to complete...

~~~
jessaustin
In North America, I've always used "<valid area code>-555-1212", which is one
of the numbers for directory assistance. The area code may be varied based on
whatever location seems plausible. Unless the service insists on sending a
text or verifying the number with your credit card company (the latter seems
less common now than it used to be) there are no problems. I wouldn't worry
about "012345678"; if they didn't want that number they'd probably have
changed it by now. Maybe they want "867-5309"?

~~~
justincormack
There are reserved fictitious phone numbers in most countries you could use
[https://en.wikipedia.org/wiki/Fictitious_telephone_number](https://en.wikipedia.org/wiki/Fictitious_telephone_number)

~~~
david-given
The problem with fictitious numbers is that they normally don't look invalid.
I don't want to supply them with a contact number which merely doesn't work; I
want to supply them with a contact number which is _obviously not a real
number at a glance_. Hence why I use 0 where possible.

Ideally I'd prefer them to allow me to leave the number blank, of course.

------
Scoundreller
As a Canadian, where postal costs have a space in the middle, I love how forms
will reject them because I included the space, or failed to include it.

With all the code they wrote to generate that pop-up, you'd think they could
massage my input into the format they wanted in the first place...

~~~
markdown
Do you mean postal (aka zip) codes?

There any many countries without postal codes at all, and we have to enter
fake numbers to validate forms.

[https://gist.github.com/kennwilson/3902548](https://gist.github.com/kennwilson/3902548)

~~~
jordigh
> postal (aka zip) codes

Post codes aren't quite the same thing as Zone Improvement Plan codes. ZIP
codes are just the peculiar implementation in the US of the general post code
concept.

An important difference between ZIP codes and Canadian post codes is that,
since there are many more possible post codes than ZIP codes, post codes tend
to cover much smaller regions than ZIP codes. In many cases, only a handful of
individuals up to a single individual may have a Canadian post code. Thus,
publishing Canadian users' post codes can severely harm Canadians' privacy, as
you may as well be publishing their exact address.

~~~
greenyoda
9-digit ZIP codes in the U.S. can also cover very small areas. For example, a
large building could have its own 9-digit ZIP code.

------
OJFord
I was scrolling through, feeling largely unsurprised, when:

    
    
        14. In Israel, certain advertising numbers start with a *.
    

Woah! Definitely didn't see that coming; I can certainly imagine my( prior
)self storing/passing phone numbers as some integer type.

But along with another user's comment that in Italy, leading zeroes are
required, it's clear that (at least in any international application) phone
numbers need to be strings.

~~~
noselasd
If you store phone numbers as integers (you normally should not), remember
that leading zeroes are significant. 0123 is not the same as 123. But as
integers they normally are (And make sure your parser doesn't parse 0123 as
octal).

~~~
jdavis703
Also my U.S. phone number used to be 703-6XX-XXXX (digits omitted for
privacy). That's not going to work if you store it as a 32-bit integer (when I
was a dumb college student I made a similar mistake, and spent a couple of
minutes scratching my head over why my number kept changing to 214-748-3647
every time I saved it to the DB).

~~~
raw_creations
"Somewhere in Dallas, some poor bastard is wondering why his phone rings off
the hook with calls for the Nevada Division of Mental Health & Developmental
Services, the Jackson County Florida Chamber of Commerce, a yacht club in New
York….." And NASA, apparently
[http://sbir.gsfc.nasa.gov/award_firm_list/selection_nid/3513...](http://sbir.gsfc.nasa.gov/award_firm_list/selection_nid/35136)

------
shifte
> A phone number uniquely identifies an individual

As someone who travels a lot I can attest to the annoyance of messaging apps
which identify users by phone number. WhatsApp is a good example.

Another terrible design is one time passcodes which are sent over SMS. When a
number gets recycled it can become impossible to recover access to a service
which you forgot was associated with the number you had at the time of signing
up in another country.

------
Scoundreller
I have a toll-free 1-8xx number.

Since I often change cell phone numbers because I move frequently (nationwide
free long-distance has never caught on in Canada), I like having one number I
can re-direct as needed. When I go overseas and buy a local SIM card, I'll re-
direct it to that so I can keep in touch.

Telecoms have said they can't take it. The government tax agency can't accept
it. Banks won't accept it.

Now when I call in and they ask what my phone number is to verify my identity,
I have to rhyme off a string of old phone numbers.

~~~
nbb
Wait, all of your phone numbers rhyme?

~~~
nommm-nommm
"rhyme off" is an idiom. It means to recite a list of items.

~~~
Kliment
Presumably derived from medieval mnemonic texts, which used rhyme as a method
for memorizing large bodies of text.

------
f_allwein
Another common falsehood would be "phone numbers everywhere are structured the
same as in the US", e.g. with a three letter area code.

~~~
Symbiote
Or the assumption that all numbers in a single country are formatted the same
way.

020 1234 5678 London.

0121 123 4566 Birmingham.

01234 567 890 Some small town somewhere.

07987 654321 Mobile. (Is that right? Maybe a second space.)

~~~
walshemj
I have always seen the uk non metropolitan addresses written as 01234 567890.

~~~
Symbiote
You are correct:
[https://en.wikipedia.org/wiki/Telephone_numbers_in_the_Unite...](https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom)

------
geekfactor
Just ran into this the other day. A popular ride sharing app has a huge
security hole wherein if you get a recycled mobile number you can easily gain
access to the account details of the previous owner of the number and run up a
bill on their credit card.

~~~
byroot
About 2 years ago I got a new number and I started receiving facebook
notifications from the previous owner as SMS with autologin links in them.

------
tomschlick
It's just easier to treat phone numbers as a 100 character string in your DB.
For validation & formatting, I have just sent it through Twilio's loookup api
(which i believe is powered by google's libphonenumber).

------
greenyoda
Another way that a phone number may become invalid is that its area code can
change. For example, if an area code runs out of assignable numbers, it can be
split into two or more area codes and some numbers in the old area code will
be assigned a new area code.

Alternatively, new area codes can be overlaid on top of existing ones - in
NYC, Manhattan has 212, 646 and 917. A phone number that's invalid one day can
become valid the next day if a new area code is introduced.

~~~
jcrawfordor
When I was a kid, Portland, Ore. outgrew area code 503 and was issued an
overlay area code, 971. To try to prevent confusion, the phone provider, which
I believe was still USWest at the time (later Qwest later CenturyLink) made
the area code mandatory. All the sudden dialing the 7 digits on most
advertisements got you a recording: "Ten digit dialing is now required in the
Portland area..."

Many years later, a friend borrowed my cellphone in an area where phone
numbers were often dialed as seven digit. Not thinking about my being from out
of state, he only dialed seven digits, and happened to get some rather
confused person back in Portland. I had no idea my cellular carrier would even
allow you to do that!

So overlay area codes can combine with number portability to have some odd
results. A number may or may not be considered valid by the carrier, and may
or may not get you who you expected, and in edge cases this may depend on the
carrier.

------
EGreg
At least the main part of phone numbers is true: they are scarce, which makes
them the main way to prevent sybil attacks. Facebook accounts are a distant
second. Throwaway emails make sybil attacks very common on sites that let you
sign up with an email.

[https://www.technologyslegaledge.com/2014/04/telephone-
numbe...](https://www.technologyslegaledge.com/2014/04/telephone-numbers-an-
infinitely-available-scarce-resource/)

Does anyone know of any other easily verifiable resource which is on average
available to very nearly one per person?

~~~
pavel_lishin
Credit cards - although people typically have more than one.

~~~
kuschku
On the other hand, a huge group of people — Germans — usually has none.

~~~
eru
Or lots of people in poor countries, I imagine.

~~~
kuschku
Yes, but for startup people only focusing on numbers, losing 80 million well-
off people might be more relevant.

------
klagermkii
An issue I don't see raised here is the complications from Mobile Number
Portability, where one may use different services to send text messages to
different networks in a country and wrongly rely on the number prefix to
identify the mobile operator.

------
dyates
I remember being greatly annoyed at a version of Google Hangouts that would
pop up a message about certain phone numbers being too long whenever I opened
SMSs from them, and then flat-out refuse to let me reply to them.

In South Africa, we have a lot of SMS services that tack five or so digits
onto the ends of normal numbers as unique identifiers, so what I assume was a
programmer's false belief about phone numbers did some real harm there.

------
ajmurmann
A related falsehood that is built into many systems is the believe that zip
codes don't change and that new ones won't be created. A co-workers area got a
new zip code resulting in many months without properly working health
insurance because computer systems kept flashing his zip code as invalid
despite the new zip having been issued years ago.

------
jloughry
Years ago, North American area codes always had a middle digit of 0 or 1. This
led to the practice of storing a phone number efficiently in 32 bits by
swapping the first and second digits. It yielded a value that would fit in a
32-bit integer; for example, (912) 350-8000 became 1923508000.

This method broke in 1995.

------
zhemao
> phones in the disputed territory and partially recognised state of Kosovo
> may be reached by dialing the country calling code for Serbia (+381),
> Slovenia (+386), or Monaco (+377)

Monaco? WTF? And Slovenia doesn't make much sense either. Why wouldn't it be
Serbia and Albania?

~~~
nommm-nommm
I wondered about this too.

It appears to be because one of their mobile phone service provider's network
is managed by Monaco Telecom.

[https://en.wikipedia.org/wiki/Post_and_Telecom_of_Kosovo](https://en.wikipedia.org/wiki/Post_and_Telecom_of_Kosovo)

~~~
phillc73
I wondered too, and thought perhaps they meant Montenegro (+382), which is
right next door to Kosovo. Apparently not.

------
alister
> _In Brazil, to dial numbers internally but across a certain geographical
> boundary, a carrier code must be explicitly dialed to say which carrier you
> will use to pay for the call._

Any Brazilians here who can confirm whether this is true?

I know that in Brazil you can select a preferred carrier for a long-distance
phone call by dialing a prefix. For example, you'd dial 014 ahead of your
phone number to choose Brasil Telecom or 021 to choose Claro. But this is
optional as far as I know. If you don't dial any prefix, you get a default
carrier.

------
baudehlo
It's a shame despite the title there were no tips for using libphonenumber in
the article. It's a very finicky library. You have to clean your inputs a lot
before using it.

~~~
lucaspiller
There are also a lot of edge cases where I've found it doesn't work. Phone
numbers change all the time, so if you are using this library you need to
update it constantly, and even then it may still be outdated for new changes.

If I need to validate a phone number is correct I'll send an SMS and ask the
user to enter a code, otherwise I'll assume they know their phone number
better than me.

~~~
mratzloff
Unless it's a landline...

------
rwmj
> "Phone numbers are always written in ASCII"

This one got me when I ran a Japanese website. Unicode (deriving from Japanese
standards) has "fullwidth forms" for Roman letters and numbers. Thus your
users can enter a phone number as 0123456789 or ０１２３４５６７８９ (or even a
mixture), and your code had better be able to cope with it.

------
JshWright
If you're dealing with phone numbers, always normalize to E.164. It doesn't
solve every problem, but it does a pretty good job of consolidating phone
number issues to one place in your code (namely, the place where the E.164
normalization occurs).

If you're dealing with short codes or other highly regional things... Good
luck...

------
elcapitan
Those falsehoods looked less problematic than the prior ones about names and
addresses. Maybe because phone numbers still are technical things, numeric,
and less culturally coded over hundreds and thousands of years.

------
gbin
Bottom line: phone numbers are really bad identifiers !

~~~
alexvoda
Yup, along with addresses, names, other identifiers and combinations of the
above. To the irritation of those wanting to use natural keys.

------
nickpsecurity
Love articles like this. Learned some surprising things from it. Thanks to
greenyoda for the others.

------
eru
How about `everyone has a phone number'?

------
contingencies
_1\. Phone numbers that are valid today will always be valid. Phone numbers of
a certain type today (e.g., mobile) will never be reassigned to another type.
[...] Tip: Don’t store properties for a phone number such as validity or type.
Check this information again from the library when you need it._

Not sure this suggestion is a truly pragmatic approach, because there is often
very little else to determine SMS reachability up front, which is a common
want. One might assume mobile until an adequately reliable SMS provider
determines that the number is in fact not a mobile reachable SMSC-managed
number. Fun fact: in China, there used to be multiple mobile messaging systems
including a non-SMS system with weird gateway restrictions and no UCS-2
Unicode support. Another fun fact: UCS-2 kills bytes rapidly, you are better
off (ie. get more length per message) using legacy local encodings like TIS in
Thailand, etc. from a cost/length perspective. If you want to achieve that
today, almost no mobile messaging provider can help you, you need to build
custom SMS PDUs through their binary PDU submission interface, which is
documented but still something of a black art and typically has very different
reachability constraints to standard messaging (whole operators may suddenly
become inaccessible).

 _2\. A phone number uniquely identifies an individual [...] It wasn 't even
that long ago that mobile phones didn't exist, and it was common for an entire
household to share one fixed-line telephone number. In some parts of the
world, this is still true, and relatives (or even friends) share a single
phone number._

This may be true, but on a related note, it is the trend now in many countries
to require formal government identity document submission in order to obtain a
SIM or make it functional through user registration. Therefore, in some parts
of the world, you can skip a whole lot of mucking around with mobile-connected
services by re-evaluating the probable bad-actor risk metric for customers
from those countries through considering probably relatively strong police
identification efficacy of abusive accounts in these markets.

 _3\. An individual has only one phone number. [...] Obviously, this isn 't
necessarily true._

An individual has zero or more numbers which are not necessarily unique to
that user, long term accessible, or of any certain or constant type or origin.
Someone else may take these over at any time, so they cannot be relied upon
solely as a trusted channel to the user.

 _5\. Each country calling code corresponds to exactly one country [...] The
USA, Canada, and several Caribbean islands share the country calling code +1.
Russia and Kazakhstan share +7._

This is only half true. They generally have longer prefixes. For example
[https://en.wikipedia.org/wiki/Khazakstan](https://en.wikipedia.org/wiki/Khazakstan)
shows +7-6xx, +7-7xx and much of the +1's can probably be reliably split
through prefixes.

 _6\. Each country has only one country calling code_

Further example: calling Taiwan via China.

Another point: some endpoints need PABX suffixes to reach, for example
voicemail or via corporate systems. There is no real standard for these
programs, which tend to incorporate functions like "wait for initial
connection", wait x seconds", "wait for a sound", or "wait for a second
dialtone". In some countries people will write 123456 x7 for extension 7, but
often multi-level inputs may be required (classic case: almost any telephone-
based customer support system), in which case there is no standard.

Finally, I was inspired by this document to write a similar one about
International Bank Account Numbers (IBAN), see
[https://news.ycombinator.com/item?id=11321785](https://news.ycombinator.com/item?id=11321785)

------
kazinator
> _ITU says things like "national numbers can not be longer than sixteen
> digits" but valid numbers in Germany have been assigned that are longer than
> this._

German doesn't really have long phone numbers. Those are just phone number
_phrases_ made of individual small phone numbers, but strung together by the
German writing system.

:)

------
thinkpad20
I find the title of this article condescending. The falsehoods given in this
list are surely not believed by all programmers (much less the ones who need
to work with phone numbers), and moreover I'm sure belief in them is not
exclusive to programmers. I might be off-base in this criticism, but to me
starting off with "let me show you how you're wrong" is not the best way to
engage your readership. Perhaps a better title would be "common misconceptions
about phone numbers" or "things to keep in mind when programming with phone
numbers".

~~~
csydas
I can appreciate that it is an aggressive (arguably clickbait) title and can
be off-putting, I think the reason there's a focus on programmers is because
most other professions will not need to ever know or consider most of these
facts about phones ever.

The focus on programmers is because virtually every point is about handling
phone numbers as data to be processed and worked with, which is a fairly
unique perspective that, as far as I can think, only programmers have. Most of
the points are pitfalls that might trip up a programmer when working with code
that takes a phone number as an input and needs to validate it.

While I'll grant that your alternative titles are much less aggressive, the
original title really isn't condescending unless you read into it as such, in
my opinion. It doesn't say "all programmers", just programmers, and all points
seem like fairly common misperceptions.

