For example:
Say I have classes A
, B
, C
. I have two interfaces, lets call them IAnimal
and IDog
. IDog
inherits from IAnimal
. A
and B
are IDog
s, while C
is not, but it is an IAnimal
.
The important part is that IDog
supplies no additional functionality. It is only used to allow A
and B
, but not C
, to be passed as an argument to certain methods.
Is this bad practice?
Best Answer
Interface that has no any member or has exactly same members with another interface that is inherited from same interface called Marker Interface and you are using it as a marker.
It is not bad practice but interface can be replaced by attributes(annotations) if the language that you are using support it.
I can confidently say that it is not bad practice because i have seen heavy usage "Marker Interface" pattern in Orchard Project
Here is sample from Orchard project.
Please refer to Marker Interface.