C
Charlton Wilbur
PJH> And I hope it isn't. Local conventions for phone numbers,
PJH> street addresses, etc. differ a lot, and software tends to be
PJH> used outside that local context. Forcing a non-US customer to
PJH> guess US conventions, or worse, rejecting a phone number
PJH> because it has too many or too few digits is a major annoyance.
Of course - but if we tried to get a candidate to write code to validate
*any* phone number worldwide, it would take unreasonably long for an
interview. And we'd need to have a considerably more extensive spec.
The question is useful because it's slightly open-ended, especially
phrased that way. Candidates who ask "Hm, are we matching US phone
numbers or phone numbers from anywhere?" are showing that they are aware
that the practices in the US are not universal, which is a very good
trait to have when you're developing software that's used around the
world.
But it's an interview question aimed at assessing the candidate's
fluency with regular expressions. Because of that, it helps to keep it
in a domain that people are familiar with, both in terms of valid input
(you can reasonably have both 7-digit and 10/11-digit US phone numbers)
and in terms of what fool things people are likely to do (do they write
the phone number 1 (617) 555-1212? 617.555.1212? 1-617-555-1212? is
16-17-5551-212 correct?)
So the goal of the exercise -- what you need to pass with flying colors
-- is to come up with a snippet of code or a regular expression that
matches a US phone number, and an acknowledgement that phone systems in
other countries have different formats for their phone numbers.
Charlton
PJH> street addresses, etc. differ a lot, and software tends to be
PJH> used outside that local context. Forcing a non-US customer to
PJH> guess US conventions, or worse, rejecting a phone number
PJH> because it has too many or too few digits is a major annoyance.
Of course - but if we tried to get a candidate to write code to validate
*any* phone number worldwide, it would take unreasonably long for an
interview. And we'd need to have a considerably more extensive spec.
The question is useful because it's slightly open-ended, especially
phrased that way. Candidates who ask "Hm, are we matching US phone
numbers or phone numbers from anywhere?" are showing that they are aware
that the practices in the US are not universal, which is a very good
trait to have when you're developing software that's used around the
world.
But it's an interview question aimed at assessing the candidate's
fluency with regular expressions. Because of that, it helps to keep it
in a domain that people are familiar with, both in terms of valid input
(you can reasonably have both 7-digit and 10/11-digit US phone numbers)
and in terms of what fool things people are likely to do (do they write
the phone number 1 (617) 555-1212? 617.555.1212? 1-617-555-1212? is
16-17-5551-212 correct?)
So the goal of the exercise -- what you need to pass with flying colors
-- is to come up with a snippet of code or a regular expression that
matches a US phone number, and an acknowledgement that phone systems in
other countries have different formats for their phone numbers.
Charlton