[KLUG Programming] questions on picking data types
Andrew Thompson
tempes at ameritech.net
Fri Jul 16 01:18:29 EDT 2004
On Thu, 2004-07-15 at 23:44, Robert G. Brown wrote:
> If any phone number is an instance of a class (aka an object), we can
> do a really good job of dealing with phone numbers in all kinds of
> useful ways....
>
> 1. We seperate the data value from the data representation. We are
> thus free to use any data representation we like, and represent
> it any way (or ways) we want.
>
> 2. We hide the actual nature of the data value, and protect it
> from all kinds of erroneous changes.
>
> 3. We can specify all the code that will work directly with that
> data, so it will be easier to preserve the integrity of the
> information, and ensure that the data value does not take on
> impossible values.
>
> sounds pretty good, eh? It's what OOP really means, and it's often
> not easyt work. On large, complex systems, it pays off.
Good points, all. Personally, I was ready to jump down people's throats
with "DON'T USE INTEGERS TO STORE SSNs", but it's not really that big a
deal. On the other hand, I still don't consider it wise to assume that a
data element called a number (as in ID number) is best stored that way,
especially if there's any chance its format may change. I mean, you can
talk about accommodating an extra digit, but what if some wiseacre
decided to add a letter instead? And NOT limit it to one of the first
six?
Personally, I would suggest that when it comes to formatted text like
SSNs, internal storage efficiency is somewhat less important than
accurate recognition and representation. Regular expressions all the
way!
--
Andrew Thompson <tempes at ameritech.net>
The Imagerie
More information about the Programming
mailing list