Consider this:
use strict; package Foo; sub new { my $class = shift; my $self = bless {}, $class; $self->_init; return $self; } sub _init { my $self = shift; $self->{important_flag} = 1; } package Foo::Bar; use base 'Foo'; sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->_init('har har har'); return $self; } sub _init { my $self = shift; $self->{ext_prop} = $_[0]; } package main; use Data::Dumper; my $foo = Foo->new; my $bar = Foo::Bar->new; print Dumper([$foo, $bar]); __END__ $VAR1 = [ bless( { 'important_flag' => 1 }, 'Foo' ), bless( { 'ext_prop' => 'har har har' }, 'Foo::Bar' ) ];
The author of Foo::Bar probably didn't know about Foo's &_init, and shouldn't have needed to either. Private methods are private methods. If you want your method to be overridable you shouldn't use a leading underscore and you should document it. Using method invocation on private methods isn't a problem for the module author, it's a problem for those that try to inherit it. If I use a leading underscore on a method in my module I expect that no one else runs it -- that counts for both deriving and derived classes. I also expect no one to override it. If I wanted that I wouldn't use a leading underscore.

In reply to Re: Re: Re: Re: Re: Re: Tie-ing hashes clobbers data by Anonymous Monk
in thread Tie-ing hashes clobbers data by Dave05

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.