Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Your question's a bit vague so I may be off chasing untamed ornithoids here; you might provide some more concrete, actual code and get a more relevant answer. That caveat aside . . .

It may be a side effect of your example wording but that almost sounds more like you want to model a has-a relationship rather than is-a. A Robo has an Arm, Feet, and a Head (of whatever cardinalities); but the whole in and of itself isn't a more specialized type of Arm. You'd then set up some sort of delegation on the Robo instance so that when you call aa Arm method it calls that method on the Arm instance belonging to it instead. If you're using Moose or the like there's going to be a handles declaration which you can say that calls to some set of methods should be forwarded to be called on the value in that slot. See Moose::Manual::Delegation for more details on wiring that up.

You then don't need to worry about chaining superclass constructors and what not, you just create your part instances and pass those components to the containing class' constructor.

Edit: Tweaked wording a bit. This SO thread (specifically the first answer's examples) may make more clear what I'm saying WRT inheritance versus composition.

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: How to sub class-es by Fletch
in thread How to sub class-es by exilepanda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2022-01-22 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (63 votes). Check out past polls.

    Notices?