in reply to Inheritence confusion contd...

First, a bit of meta-discussion. You should usually use the [id://...] syntax to link to other nodes. Also, this should probably just be a reply to the original node. If you have reasons for elevating it to a new top-level thread, you should at least mention them.

Now, as to your question itself. Note in the_slycer's original post, he says:

So, one way around this is to write a custom ls subroutine in the Custom::FTP module, but this seems to be "wrong" in that it's not inheritance of any kind, rather it's overriding every routine in the Net::FTP module to simply call the parent class's routine..

It sounds to me that this is exactly what you're proposing. In short, you're suggesting a workaround that he already thought of and rejected.

Update: and after reading the thread, it becomes obvious that this strategy was discussed at length already. Is there something about your post that I am misunderstanding?

Replies are listed 'Best First'.
Re^2: Inheritence confusion contd...
by GoCool (Scribe) on May 25, 2005 at 17:23 UTC
    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?

      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.