[Pdx-pm] Too much validation

Wil Cooley wcooley at nakedape.cc
Thu Nov 20 00:56:19 CST 2003

On Wed, 2003-11-19 at 22:39, Joe Oppegaard wrote:

> So as a general rule of thumb, when should data validation be done?
> Catch it early or catch it when it actually matters? Or both? (Ugh,
> duplicate code).

My guess (and IANAExpert) is that it should probably be done in both,
depending on the circumstances.  If you're writing a module or anything
where you expect reuse, you should treat it as a black-box and make it
as robust as possible.  OTOH, if you're following an XP/YAGNI approach
early in releases, then probably it's fine to just have it in one place.

I've often wondered if it wouldn't be better to use objects instead of
basic strings for a lot of attributes, where the class implements robust
validation checks.  How many places splattered throughout your code is
the regex for testing if a telephone number or IP address is valid?  Why
do OO languages rarely ship standard with classes for common data

Wil Cooley                                 wcooley at nakedape.cc
Naked Ape Consulting                        http://nakedape.cc
* * * * Linux, UNIX, Networking and Security Solutions * * * *
*   Naked Ape Consulting                 http://nakedape.cc  *
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.pm.org/pipermail/pdx-pm-list/attachments/20031119/e24df785/attachment.bin

More information about the Pdx-pm-list mailing list