From: Sean O'Dell Date: 2003-11-21T02:35:05+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) On Thursday 20 November 2003 08:58 am, 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 Yes, because I don't know what sort of object has the #drive method. It's not an object I am familiar with, and I don't even know what #drive is supposed to do. An error message that like just says to me "something is very wrong, and you don't know what." Opening up the source and looking at the line won't necessarily tell you anything. You could be there for awhile looking around trying to figure out what the code does. It's not an efficient way to debug at all. Sean O'Dell