This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
Joined: Jul 25, 2008
do you mean hidding is used only for static methods?