in reply to Testing Edges
One of the cool things in perl, to me, is the fact that perl often does what I mean, even if the author of the subroutine didn't intend for it. For example, in the thread "Should Modules Do I/O?", there's a deep question about writing directly to files. One of the solutions is to write to a filehandle. Now, the really pedantic may check that the file handle given actually is a GLOB, or may instead check that it's an IO::Handle. But what if I, instead, created my own object that did something truly funky, and implemented all the functions that you call, which did some other sort of magic to the data? It may not be derived from IO::Handle, but it works just fine!
Or maybe you want to take a callback function. If at all possible, use the $object->$function(@params) syntax for callbacks - this allows an incredible amount of flexibility. I can give you a function name (string), or I can give you a code-ref. And your code will just work... and so will mine.
My point is to be very careful about what you validate. Sometimes you need to validate, but other times you're just getting in the way of the natural, perlish flexibility of your function.
|
|---|