Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Perl-Sensitive Sunglasses
 
PerlMonks  

•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
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181044]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2014-04-17 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls