Raymond DeCampo coughed up:
Tim said:
Tim Tyler wrote:
quoted:
yes, but the discussion is more about the case when you make a
mistake and you don't override a method that you should actually
override.
Some way of indicating methods that *must* be overriden in
subclasses may be an idea with some virtues.
That's what the abstract keyword does.[...]
...except that it doesn't work under some circumstances - thus my:
"unless you really need a base class implementation [...]" comment.
I afraid you've lost me here. What use is the base class
implementation if your intent is that every subclass override the
method?
If you intend to have every subclass invoke super.method1(), then it
would be better to have method1() be abstract in the superclass and
ask every subclass to invoke super.method2(), where method2() is
protected.
Or actually, what would be better, would be to make method1() final in
the base class, have it invoke method2() and make method2() abstract
and protected.
So I don't really see the case you are addressing here.
I see that. You're missing the following notion I think:
Given two classes, in this relationship:
A <|-- B
Given the method
A.method()
It is not amazingly uncommon to see a situation where the designer wants an
implemented A.method() because the A class must be instantiatable, but for
all subclasses to require that the subclass override it with one of their
own. If the method were declared.
public abstract void method() {...}
Then there would never be any way to instantiate an A by itself. You can
make arguments as to whether or not this is something "good" to do in OO,
but I believe that it would be a "fine" thing to do if you had a keyword
enforcing it:
public must_override void method() {....}
But I'm not prepared to go to war over the notion. I've seen things be
declared non-abstract for this very reason alone.