Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

•Re: Re: ?Re: RFC: Class::DispatchToAll

by merlyn (Sage)
on Jul 11, 2002 at 15:26 UTC ( #181044=note: print w/replies, xml ) Need Help??

in reply to Re: ?Re: RFC: Class::DispatchToAll
in thread RFC: Class::DispatchToAll

Again, multiple inheritance is a broken concept in general. This whole thing reeks of "bad design".

Why would you be passing control from your derived method to a base method that might fail? You should be calling it directly, taking the results (or none), then deciding whether or not to call the next. Again, when you inherited from the multiple base classes, it's your responsibility to decide how to handle the multiple dispatch. And that's what NEXT is for.

-- Randal L. Schwartz, Perl hacker

  • Comment on •Re: Re: ?Re: RFC: Class::DispatchToAll

Replies are listed 'Best First'.
Re: ?Re: Re: ?Re: RFC: Class::DispatchToAll
by frag (Hermit) on Jul 12, 2002 at 05:08 UTC
    I don't think I explained myself well, or else I'm not understanding your criticism. I am talking about calling a set of methods from parent classes, taking the results, and deciding whether or not to call the next. (domm's module doesn't do this checking, but it wouldn't be hard to incorporate it. In any case, in this sort of design you must take into account the possibility that all the parental methods would be invoked anyway.) It's set up so that this is only true for a given, fixed set of functions; functions that can be clearly traced back in the code. (These functions are also documented thoroughly and are vetted to be free of side-effects upon non-localized data. I agree with you about the importance of discipline in OOP.) It seems to me that this actually solves one of the major multiple inheritance headaches, by designating a method in the child class that acts as a wrapper for all of the parental methods that attempt the same function.

    Note that I misspoke in my earlier comment about wrapper methods; essentially, that's all this is, dispatch being controlled and monitored by a single method. You've got a generic wrapper method in the child class that takes the names of the parental methods that it should handle. This does not vary at run-time, but is a constant within the child class that is handling the dispatch.

    Also please note that I am not arguing that multiple inheritance is some sort of no-brainer to be used cavalierly. I am saying that I have found a particular situation where I think it makes sense. I don't question that this is a single solution to a limited set of problems.

    Finally, I have to admit that I just don't see that NEXT is always the best approach. NEXT allows each method in the parent class to make its own decisions about whether to continue dispatch or not. But it seems more natural to me, and safer, even, to have a central method oversee the process.

    -- Frag.
    "It's beat time, it's hop time, it's monk time!"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181044]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2018-06-19 14:18 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.