Ben Giddings wrote:

>On Fri August 8 2003 2:36 pm, Chris Morris wrote:
>  
>
>>Ben Giddings wrote:
>>I agree with Ryan's reply to you. If I only need the one method on the 
>>object I'm interacting with -- should that one call not be allowed 
>>simply because all of the other methods that I don't need aren't 
>>consistent with what it *should* be?
>>    
>>
>
>Ouch, this is one of the most difficult-to-understand sentences I've seen in a 
>long time.
>  
>
Wow ... you're right. That's ludicrous ... must be Friday :-)

Back to your first post I replied to:

>In Java you could check to see if something is of a certain class, but what 
>was more often done was to see if something implemented a certain interface.  
>Implementing an interface was a way of signalling "I declare myself to act 
>like a duck".  And the fact you implemented the interface meant that you had 
>all the necessary features to act like a duck.  You weren't allowed to 
>implement the interface and then only choose certain duck-like features.
>
>It seems to me that duck-typing in Ruby should strive for the same thing.  
>Checking for one method isn't enough, in my opinion.
>
I guess I just enjoy the freedom Ruby gives me. Statements like "You 
weren't allowed to implement the interface and then only choose certain 
features" now bug me, because a required typing system has gotten in my 
way too many times in my Delphi coding.

As David Black pointed out, Rubyists tend to be fanatical unit testers. 
Quite possibly I'm just not writing complex enough systems where your 
point would make more sense to me (honestly, not sarcastically) -- I 
automate tests on the stuff I write so it seems I don't really have to 
worry too much about contracts and the like. The places where I can just 
stick in a method name and not be bound to all these contracts and class 
hierarchy restrictions has been very pleasant.

Ironically, the few places I can think of that I am checking for this 
sort of thing, I'm doing is_a? checks instead of responds_to? checks :-)

-- 

Chris
http://clabs.org/blogki