I would have the method X() in the children as well, and call SUPER from there if you want to run the parent method.
The problem with this (and jaa's response) is that it solves a different problem from the OP's :-)
When you specialise a method through inheritance you can either replace it completely, or add behaviour before and after it runs.
However with the OP's method:
sub X {
my $self = shift @_;
...
$self->_Private_X();
...
}
the behaviour that we want to tweak occurs in the middle of X's execution. You can't get at that by specialising X in a subclass.
You see this pattern quite a lot when you have the same skeleton behaviour with various different implementations. The OP is doing exactly the right thing in isolating this behaviour that changes in a separate method that can then be specialised in each subclass. |