[Pdx-pm] interesting testing hole thats been dug

Michael G Schwern schwern at gmail.com
Thu Jan 4 11:20:30 PST 2007

Wil Cooley wrote:
> Yes, that certainly makes sense.  It obviously doesn't make sense to
> require $obj->isa('Net::FTP'), because with duck-typing it doesn't
> actually have to be a subclass.  How thoroughly should I test with
> $obj->can() for the object's abilities?

Your code already does all the checking it needs by calling methods on $obj.  About all ->can is going to buy you is a nicer error message, but then you have to keep a duplicate list of all the methods your code calls on $obj.  Its up to how lax or strict you want to be.  Since you're allowing duck-typing you're probably lax.

More information about the Pdx-pm-list mailing list