That's an important topic. The article Overriding vs. Hiding should help you understand it.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Phil Hopgood
Ranch Hand
Joined: Jul 14, 2008
Posts: 47
posted
0
The "Overriding Vs Hiding" article is very interesting and illuminating. It raises a few question for me though:
I knew that if you wanted to invoke a class method then, since it's static (never becoming part of the instantiated object per se, only one copy and that in the class), it's more accurate (and clear) to use the dot operator on the class, i.e.
or
What confuses me is, since it's frowned upon and regarded as bad practice, why allow it at all?
Since "hiding" a class method is allowed and since you can invoke the "hiding" method through the subclass, i.e.
then you can put any functionality you like in the subclass version of the method.
So in what way is anything hidden? Granted it's not the same as overriding since it's static and you can't invoke the subclass version by using an instance variable but to me nothing seems to be hidden since if I use the right way I can use either the Foo version or the Bar version.
Regards, Phil
Agarwal Priyanka
Greenhorn
Joined: Jul 25, 2008
Posts: 20
posted
0
do you mean hidding is used only for static methods?