Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Do you know where your variables are?
 
PerlMonks  

Re^4: Private Methods Meditation

by hardburn (Abbot)
on Jul 19, 2004 at 16:48 UTC ( [id://375694]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^3: Private Methods Meditation
in thread Private Methods Meditation

Can't speak for tilly, but it's defaintely something that effects pretty much any language, though Perl might be worse off than most. If you have a method in your subclass, you always run the risk that the parent class will define a method with the same name, but with very different functionality.

I don't remember how the method is searched for in Java, but I believe that if you call that method in the parent, then it calls the parent class's version. This isn't true in Perl without some tricks.

----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.

Replies are listed 'Best First'.
Re^5: Private Methods Meditation
by Ovid (Cardinal) on Jul 19, 2004 at 16:59 UTC

    If you have a method in your subclass, you always run the risk that the parent class will define a method with the same name, but with very different functionality.

    Not so. In C++, a method must be explicitly declared as virtual if you wish to allow it to be overridden in subclasses. As a result, a if you call a superclass method and that method calls the method foo(), it will only grab the subclass foo() if the superclass had declared foo() as virtual. (At least, that's my understanding. C++ is not my strong suit.)

    In Java, you can declare a method as private and subclasses cannot override that method.

    I'm still not sure how subclassing messes with something's internals, though. In Perl, it's pretty much a given that this will happen since there is so little support for encapsulation. This ties in with my comments above. I don't know if tilly meant all OO languages.

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://375694]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.