T
Tim Tyler
Raymond DeCampo said:[...]Tim said:Raymond DeCampo said:Tim Tyler wrote:
Tim Tyler wrote:
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 can imagine it happening, though - for example if you need the base
class to continue to perform the default functionality - because you have
already released it to clients and don't want to change your interface.
You can imagine what happening? Please be more explicit.
Are you saying that you have a method in a base class that you suspect
may or may not have been overridden in third party code using your
library? Now the semantics of the base class have changed to where each
extension should supply its own overridden version? If you leave the
existing implementation won't the client code then essentially be broken
and they won't have gotten any message from the compiler or at runtime
concerning the incompatibility? Wouldn't it be better to make the
method abstract and force them to override by contract?
You've released the Base class - and it doesn't have abstract methods.
Later you discover that you want to be able to extend it in the way
under discussion. However, you can't change the methods to abstract
ones, becasue of third party code that depends on the existing
Base class interface.
You /could/ introduce a new PreBase class with abstract methods - and
extend it to produce the original Base class. However extended versions
of the PreBase class might again fail to work with the existing third
party code - which is expecting to get an instance of Base (or implicitly
a subclass thereof).