From: Austin Ziegler Date: 2003-11-20T09:21:25+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) On Thu, 20 Nov 2003 06:32:00 +0900, Sean O'Dell wrote: > On Wednesday 19 November 2003 01:25 pm, Austin Ziegler wrote: >> Since Bob is a smart programmer, he'll see in his error log: >> >> NoMethodError: undefined method `accept' for # from ... >> >> Well, this means that his File object doesn't know the method >> #accept. Therefore, he can open the source to your HTTP library >> and see "oh! this guy's expecting a Socket and has put accept in >> the wrong place!" If Bob's a really smart programmer, he'd >> already know that #accept is a Socket method. > Wrong! There's no mention of the Socket object anywhere! The only > way he would know that is by searching the source code of OTHER > METHODS that call that method, then tracing back to where the > object that is passed in was created. Then he can see Socket.new. Not really. Since Ruby is open source, he can add a quick debug print: def foo(arg) $STDERR.puts arg.inspect : : end He runs the library normally and he'll see that the incoming argument is a Socket. But there's also a neat The other point that I'll make is that I've had to deal with very similar debugging mechanisms in C, C++, and PL/SQL. > Also, don't make the assumption that the developer automatically > knows #accept belongs to the Socket object. Your familiarity with > Socket is causing you to discount the pain a developer feels when > this sort of error occurs. A developer may know NOTHING about the > Socket object and will not have a CLUE about #accept. I'm actually not that familiar with Socket at all. I just did what any Ruby developer can do in irb and discovered that Socket knows about #accept. -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.11.19 * 19.21.09