I don't personally agree with this rule (IMHO more headache than use), but the answer in the question you mentioned gives a fairly good indication of what you can do.
- Make the
checkSelf()
method final - Create an empty protected
checkSelfEx()
method inStudent
that is called as the last step ofcheckSelf()
- Implement
checkSelfEx()
in User making it final.
This guarantees that the checks performed in checkSelf()
are ALWAYS going to be performed when the method is called (hence no break of contract by subclasses is possible). The problem of course arises in naming, as if you want some more logic in a subclass of User, you would need checkSelfExEx()
. If all those checks can be grouped with a better name it is at least OK to read, but exposing a lot of final methods to subclasses is not a great thing.