in reply to Re^3: Understanding 'Multiple Inheritance'
in thread Understanding 'Multiple Inheritance'
Implement the MI such that it redispatches any method that returns a 'Not processed' code. If the first (by some defintion) subclass implementing the method returns this value, the method is redispatched to the next subclass that implements it, until one of them responds saying 'Okay, I've got that one'.
Coincedentally, that's exactly (well, almost) how Perl6 will implement it. The method dispatcher will ask all the classes involved (in some order you the programmer get to specify) who wants to handle it. Each class can be written with that in mind or they can just handle it and be selfish. But, the mechanism will exist.
The real problem with the CD player / Radio example is a that the problem was ill-conceived. A CD-player / Radio shouldn't be viewed as both is-a a CD-player and a Radio. Those items aren't the true atomic concepts as a CD-player and a Radio are each several items. A better view would be a pipeline of objects that provide for a plugin mechanism. So, you would have
Then, you build it like you have a bunch of Legos, which is how they're built in the real world. And, you do have mode switches for most of those categories which switches the active FOO from A to B. In other words, the actual physical item is built with composition, but the Foobars each inherit from some base Foobar for an interface and some common implementation bits.
Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Understanding 'Multiple Inheritance' (hindsight)
by BrowserUk (Patriarch) on Mar 07, 2005 at 14:46 UTC | |
by dragonchild (Archbishop) on Mar 07, 2005 at 14:53 UTC | |
by BrowserUk (Patriarch) on Mar 07, 2005 at 15:14 UTC | |
by punkish (Priest) on Mar 07, 2005 at 15:22 UTC | |
by dragonchild (Archbishop) on Mar 07, 2005 at 17:20 UTC | |
by BrowserUk (Patriarch) on Mar 07, 2005 at 18:21 UTC |