in reply to Re: Inheritence confusion contd...
in thread Inheritence confusion contd...

Thanks for those tips, i'll remember them.
Maybe i'm not making things clear, the Custom::FTP module does not need to override the ls() subroutine but just use the one available through the parent class i.e. Net::FTP and to be able to use Net::FTP's ls() subroutine, he needs to have
$ftp->{parent}->ls() instead of
$ftp->ls()

Any better this time?

Replies are listed 'Best First'.
Re^3: Inheritence confusion contd...
by revdiablo (Prior) on May 25, 2005 at 17:32 UTC

    Do you mean that users of the module should use $ftp->{parent}->ls? If that's what you mean, then I think that would be a bad idea. It violates encapsulation, and looks like a fragile interface indeed.

    But if you mean that the Custom::FTP should have its own ls method that calls $ftp->{parent}->ls, then my original comment still holds. That is exactly what the_slycer was implying when he wrote, "one way around this is to write a custom ls subroutine in the Custom::FTP module."

    As a side note, the solutions offered in the original thread are good ones. You should read them and try to understand them. And if you have any questions about those solutions, you should ask. It's not that I don't want you to ask questions, but just that I want to help you ask the right questions. :-)

      "Do you mean that users of the module should use $ftp->{parent}->ls? If that's what you mean, then I think that would be a bad idea. It violates encapsulation, and looks like a fragile interface indeed."

      I see exactly what your saying regarding the interface to users ending up being fragile and it makes perfect sense now.

      Thanks for helping me understand.