Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Decorator(?) classes and inheritance

by duff (Parson)
on Jan 30, 2004 at 16:15 UTC ( [id://325270]=note: print w/replies, xml ) Need Help??


in reply to Decorator(?) classes and inheritance

The actual problem is I have a baseclass A and two children B and C, each overriding a different method in A. How do I have D inherit from B and C and have both overriden methods without having D know about the innards of A, B, and C?

Um .... you don't. As you've framed it, it seems that D needs to know that B and C have overridden different methods and that it wants both. One way to get D to do what you want is for D to define those methods itself and call the appropriate ancestor:

# Say B overrode method foo() and C overrode method bar() package D; sub foo { &B::foo } sub bar { &C::bar }

Replies are listed 'Best First'.
Re: Re: Decorator(?) classes and inheritance
by dragonchild (Archbishop) on Jan 30, 2004 at 16:50 UTC
    In most OO languages (from what I have gathered), doing what I want to do should be no problem. I'm running straight into the brick wall of depth-first @ISA searches for methods. I want to change SUPER to be breadth-first. NEXT doesn't do what I want cause it continues the depth-first search, just allowing that the search could backtrack past the re-dispatch. What I really want is use redispatch 'breadth-first'; (as opposed to the default use redispatch 'depth-first';).

    ------
    We are the carpenters and bricklayers of the Information Age.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      Which other OO languages? The only thing i can think of is the weird C++ thing where the constructors of all the classes you inherited from get called too, but that might actually confuse your problem more than make it simpler. You are looking for your classes to dispatch in a more intelligent way, but I dont think you are giving them enough info to do that with.

      Again, more code (runnable real code not pseudo-code) would really help us in figuring this out.

      -stvn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-18 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found