From: Richard Kilmer Date: 2003-11-06T01:33:41+09:00 Subject: Re: Managing metadata about attribute types On Nov 5, 2003, at 10:58 AM, Chad Fowler wrote: > On Wed, 5 Nov 2003, Richard Kilmer wrote: > > # > # This goes beyond just setting attributes. Many methods need > parameters > # that are not simply attr_accessor methods. Those parameters are > # going to be an object. The question is whether you write your > methods > # to expect a certain "namespace" (Class/Module), or just simply a set > # of behaviors. > # > > Thank you, Rich. This is the first time I remember seeing classes and > modules referred to as "namespaces". In the Ruby world, this is really > the way to think about them. Classes and modules are, among other > things, > a method of grouping behaviors. And, like other namespaces, this set > of > behaviors might change. So, testing for the namespace is rarely > useful. Right. The big reason for testing the namespace for an object that you are sending a message into is to disambiguate the message. For example if you had two classes: class Tree def bark @bark end end class Dog def bark p 'Woof!' end end Sending the message "bark" on a Tree returns an attribute (the 'Bark' instance) and the message "bark" on a Dog has the dog act ("Woof!"). Again, I find this ambiguity rarely creeps into a Ruby application, and I have written many Ruby projects of size.