From: Hugh Sasse Staff Elec Eng Date: 2001-06-27T21:43:20+09:00 Subject: [ruby-talk:16965] Re: Method overloading (option) Was: Re: On Wed, 27 Jun 2001, Yukihiro Matsumoto wrote: > I admint explicit dispatch based on type often comes first to mind. > But I think things go better if we design programs based on protocols > (i.e. based on set of methods that objects can respond). I think this is because people "encapsulate" the collection of methods that something will respond to as being a type. A problem of listing methods and testing thing.responds_to?(aMethod) is that as your code makes use of more methods as it grows, you have to add them to the tests. Because of modules, an object with given type may have methods mixed in, so type() tests are inadequate anyway. So what do you see as the elegant, ruby way of overcoming this problem? Are you saying there is a way without dispatching on type or on "responds_to?", when you talk about protocols? Or are you saying there is a good way to collect the "responds_to?" tests together, neatly? > > matz. > Hugh