A gotcha of note. i came across some code that went something like the following.
setup as such:
ClassB inherits from ClassA.
ClassA methods:
.updateSomething
.updateAnother
ClassB methods:
.updateSomething
.updateAnother
ClassB.updateSomething looks like
public void updateSomething(...) {
super.updateAnother();
}
ClassA’s updateAnother looks like:
public void updateAnother(...) {
...
updateSomething()
}
where updateSomething() is implemented in the ClassA.
well…when you invoke updateSomething() on an instance of classB, the super.updateAnother() is called, but when updateAnother() encounters updateSomething(), it calls the subclasses updateSomething(), which in turn will do the super.updateAnother(), and there we have our infinite loop.
In short, the instance of the ClassB will *always* invoke its *own* implementations of methods, even in an execution of a superclass method.
This makes sense to me, although i don’t know if this is a universal design decision in all OO languages. I’m sure the smart people know why this design decision exists.
Definitely a subtlety, and a piece of knowledge likely gained by experience, if you haven’t studied this stuff in books.