I was stating a general rule for all OO languages. There may be additional traps in Perl, but it is true in general.

When I declare a subclass, I'm saying that A isa B. Making this work generally requires that A and B cooperate to some extent. At a minimum, the author of A needs to know what methods B is likely to expect to see overridden. Missing some of them may mean that your object behaves weirdly. Sometimes you need access to class data. In many languages the subclass implementor has access to special protected functions, and needs to know when they are supposed to be called. All of this may need updating if the parent module changes. And so on.

In short, the concept of "isa" represents reasonably tight coupling between components. Some of the tightness is accidental - such as the result of the visibility of the implementation in Perl. But some is intrinsic to what OO is. If you're unwilling to accept this coupling, then you probably shouldn't be subclassing.

Remember that OO provides a series of potential compromises between reducing duplication of information and reducing coupling. It is good to not duplicate information. It is good to have loose coupling. Those goals are good because each avoids a difficult problem. Unfortunately they naturally conflict, reducing duplicate information naturally couples things together.

Among those potential compromises, inheritance is the choice that gives the best opportunity for removing duplication of information. But at a natural cost of tighter coupling.


In reply to Re^4: Private Methods Meditation by tilly
in thread Private Methods Meditation by theAcolyte

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.