From: Chad Fowler Date: 2003-11-21T01:59:00+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) Excuse that last post. It was an abandoned one that ended up getting accidentally sent. Chad On Thu, 20 Nov 2003, Chad Fowler wrote: # qyyOn Thu, 20 Nov 2003, Sean O'Dell wrote: # # # # # A contract is any interface, and a Ruby class is an interface. True, a Ruby # # class isn't the definition of a contract, but any OO class serves the # # function well enough. Despite Ruby's flexibility, at any given point, a # # class implements an interface. It can be extended or changed, but it # # definitely describes an interface. # # # # Because no type checking at all causes non-descriptive errors when an object # # is passed to a method (2 of 1 parameters?) which expects it to have certain # # methods which takes certain parameters. Either way, an error occurs, but # # with some form of type checking, the programmer gets a much clearer picture # # of why they can't pass in a particular object to a method without at least # # some modification. # # # # # # # Example: you get an "object does not the :socket interface." You then say to # # yourself: "Ah! This library wants something like the Socket class...okay, I # # can fake that!" # # # Or how about: # # blah.rb:7:in `example_method': undefined method `drive' for "car":String # (NameEr # ror) # from blah.rb:10 # # Is there ever a chance you wouldn't understand what that means? # Personally, I would see that message, open up blah.rb, look at line 10 # # Or # # # # It's just informational. It's just for the purpose of speeding up development # # and making the code a little more robust through a good report of what is # # going wrong when someone passes in an object that can't be used by the # # method. It doesn't prove that an object correctly implements an interface, # # and the object can definitely break the interface, but the facility would be # # there for programmers who can make use of it. For those that tend to break # # interfaces when programming rather than use them properly, there are always # # QA jobs. =) # # # # Sean O'Dell # # # # # #