Reputation: 89
Is it ok if a subclass implements an interface and instead of overriding the method it puts the method in the superclass (method with same name and arguments in superclass). Diagramm 1
Or is it better to implement it like in the following Diagramm 2 ?
Upvotes: 0
Views: 29
Reputation: 340
Whether or not it is legal depends on the language you're using.
I see no reason to not implement it as shown in Diagram 2, provided AbstractSuperClass
fulfills the promise of interface1
.
This way any other future subclasses of AbstractSuperClass
would also be able to be type-checked against interface1
.
Upvotes: 1