Quote:
Originally Posted by euhlmann
Why do you need to restrict "imposter" classes? I think your second code block has the best solution.
|
Concur. The purpose of the interface is to allow a totally distinct implementation of the interface contract. While I agree that there is no clear way for an interface to enforce a contract, it is only trivially more difficult to "break the contract" for a class which extends a base class. (How many times have programmers overridden object.equals to mean something quite different than "is-another-handle-for-the-same-object"?)