Hello three18ti, and happy New Year!

The OO design I described as back-to-front was a parent class calling methods defined in its own child class. By “parent” and “child” I meant two classes related by inheritance: the child class inherits the parent’s methods (and class data), and overrides method implementations only as needed. One of the main advantages of inheritance is that it facilitates code reuse: by creating a new class and having it inherit from an existing class, your new (child) class reuses as much as it needs of the code already written in the existing (parent) class. And there should be no need for the parent to access the specialised code in its child class(es). If the parent does reference its children, a maintenance problem is created: changes to one child class propagate upwards to the parent, and then potentially back downwards to sibling classes.

I had a look at your Build::VM project, and found this module structure:

+--Build-VM/ +--lib/ | +--Build/ | | +--VM.pm (Build::VM) | | +--VM/ | | | +--Guest.pm (Build::VM::Guest)

But this module layout does not constitute inheritance! The module Guest.pm begins:

package Build::VM::Guest; use Moose; use strict; use warnings; use MooseX::HasDefaults::RO;

There is no reference to any parent class, no extends statement, so no inheritance (or ISA) relationship is established. The module VM.pm contains:

use Build::VM::Guest;

which creates a HASA relationship, which is what I recommended to the OP when I said:

I suspect what you’re looking for is a helper class which your parent class accesses via a HASA or USES relationship.

Since your Build::VM and Build::VM::Guest classes are not related by inheritance, my comments about the design being back-to-front do not apply.

Note also that Moose delegation is not inheritance-related:

Delegation is a feature that lets you create "proxy" methods that do nothing more than call some other method on an attribute. This lets you simplify a complex set of "has-a" relationships and present a single unified API from one class.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re^5: Method of child module called by parent by Athanasius
in thread Method of child module called by parent by gzartman

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.