From: Sylvain Joyeux Date: 2007-10-07T16:50:16+09:00 Subject: Re: The Case for Multiple-Inheritance > You could, of course, override #kind_of? to do what you want. Yes. I could build a MI-like pattern from scratch. I does not seem to be the "right way" ... > What Mentalguy's suggesting is that the relationships may not be best > modeled as an is-a relationship, as I suggested to Trans early on in > the discussion. Is-a relationships are very tightly coupled and should > only be used where such a tight relationship is warranted. I'm modelling activities (moving to a point, moving the camera, taking a picture at a location, this kind of things). To keep things manageable, use the inheritance relationship to express that we have abstract actions (the generic MoveTo(x, y)) and implementation of those actions (MyWayToMoveTo(x, y)). I need to reason about these relationships because you can use a specific movement method in place of a generic one, but you can't use a TakePictureNow activity in place of a MoveTo(x, y). However, you could use a TakePictureAt(x, y) in place of a MoveTo(x, y) since it is both modelling a MoveTo(x, y) *and* a TakePicture. In most cases, it is not a problem: I represent the fact that TakePictureAt(x, y) is in fact a sequence of MoveTo(x, y) and a TakePictureNow. It is therefore possible to repesent the thing with single inheritance. But there are cases where this kind of separation cannot be done -- hence the need for one class to be an implementation of multiple models. Now: why classes ? Some code is tied to the various activities (code to start the activity, to stop it, handlers when some event appear) and I do want the children models to inherit the methods of their parent models. I actuall started to write parts of my framework without using method dispatch and inheritance. It began quickly horrible, so I rewrote it using it. I'm more than happy now. I would just be happier with MI. Sylvain