On 01.08.2009 16:21, Arved Sandstrom wrote:
Lew wrote:
For the OP's purpose in particular, it makes more sense to model
an SSN as a String than an int.
In general I agree - I was playing a bit of devil's advocate. I
myself would model an SSN as a string. That the individual 3
numbers making up an SSN are not quantitative entities is
undeniable. But then again, neither are ordinal numbers, and both
the group number and the serial number behave like specialized
ordinal numbers.
I'm still not sold on the idea that there is a checksum for SSNs. I
myself don't see how there can be one. You yourself say that the
three numbers making up an SSN are independent of each other.
I would model a SSN as an SSN - meaning: since a SSN is not exactly
a number and has more properties than a simple length (for example,
a valid format) I would create a class for SSN handling. It's
likely that it will include a constructor with a String (or even
CharSequence) argument but the internal representation does not
really matter. And it can be changed, too if you notice that all of
a sudden the long you used initially is not sufficient to hold all
the relevant information. My 0.02 EUR anyway.
number from, and what I need to do with it. For example, a number of
no need to deal with them other than as opaque strings.
validation of some sort. It won't be perfect but it'll catch some typos.