One last piece on Duck Typing then I think I am about all quacked out (when will these silly puns end???).... This is in response to Dave's comments over here, as well as some clarification to the general atmosphere in regards to duck typing. First I want to make a correction, something I failed to mention in my initial post. My comment in the Duck Typing session is that I had been tinkering around with using ANT to remove type for production. Sean, I believe, misunderstood and conveyed that I was using this in production. This couldn’t be further from the truth, the bulk of our applications are legacy CF5 applications. I neglected to correct that in my original post but I wanted to make sure that is clear.
Something else I want to make perfectly clear, I 100% agree with the sentiments of Sean, Dave, and a large majority of others out there. Duck Typing is a really cool technique but it is not something to be used everywhere (read: abused), especially for performance. I'll leave it to the other 50 blog posts I've read to explain when or where it should be used. The ANT script is forcing people to put duckType="true" into their function and argument declarations for a reason; to clearly state where duck typing is being used for performance. This designation servers as documentation, for debugging. A additional intention was to force a developer to THINK before they [duck] type. What I realize is that regardless of what I have to say about not using duck typing for performance it will happen. My hope is that people are at least checking code into a source control that is not duck typed in hopes that QA, unit testing, and documentation are more accurate to the intent of the application/objects.
In direct response to Dave's comments I would like to think that unit testing would reveal something like a string passed instead of an object and that the application would be constructed to handle this appropriately. Though that was just an example and Dave's underlying point was Duck Typing for performance, no mater how you slice it, can be problematic. Dave has a perfectly valid point and I want to restate that if you insist on using duck typing for performance please please please use type restriction and return types in your development, and testing. I also want to go one record as agreeing with Dave’s other point which is database tuning can yield the highest returns in regards to performance. If you do us duck typing for performance it should be one of your last stops, not first,along the performance tuning path.