From: Jim Weirich Date: 2003-04-24T21:21:45+09:00 Subject: Re: Subject: Re: [ANN] Ruby.shop On Wed, 2003-04-23 at 23:10, Hal E. Fulton wrote: > What's your take on the circularity at the top? Chris says > that Object doesn't take anything from Class. I thought it > did. I'll have to think about that tomorrow. > > Maybe I could use magenta arrows with heads at both ends. I had to fire up IRB to investigate this. Remember, there are different kinds of dependencies/relationships. There is the releationship between a specific instance and its class (Fido is a Great Dane). There is also the relationship between a class and a more general class (Great Dane are a subclass of Dog). In Ruby, the first (object=>class) relationship is represented by the "class" method. The second (subclass=>superclass) by the "superclass" method. Since Classes *are* Objects in Ruby, every class will have an (object=>class) as well as a (subclass=>superclass) relationship. For example ... class Dog; end class GreatDane < Dog; end fido = GreatDane.new fido.class => GreatDane GreatDane.class => Class GreatDane.superclass => Dog Regarding the Object/Class/Module diagram, look at http://w3.one.net/~jweirich/images/rubycore.jpg. NOTE: I used a cheap UML drawing tool that rendered <> into ?class? when generating a JPEG file. Yuck. The open head arrows (eg. from Class to Module) represent the (subclass=>superclass) relationship. The arrows marked ?class? are the (object=>class) relationship. As you can see, *every* class object in the diagram has a class pointer to Class (even Class itself). All of the white boxes in your diagram should have a class pointer to Class. Since you are using color (White boxes for classse, blue for modules), including the class arrow in your diagram would be redundant, I think I would omit it. That would remove the apparent circularity from Object to Class. If you decided to leave it in, then I would consider adding *all* the class relationships, otherwise you leave the impression that there is something unique about Object. I also put Kernel into the diagram. Since the Kernel object is not a Class, but a Module, its ?class? arrow points appropriately at Module. I also show an ?includes? arrow from Object to Kernel. There you get an interesting circularity where each link in the circle is a different kind of link. Does this help? -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)