I have tried to google this one, but I can’t find an acceptable answer. Is interface inconsistency, when you make a class implement 2 or more interfaces which are incompatable with each other? For ex:
public interface Lion()
{
public void eat();
}
public interface Tiger()
{
public void eat();
}
public class Liger implements Lion, Tiger
{
public void eat(); //Problem: How does it eat? Like a lion or tiger?
}
Am I correct or way off base?
In Java, you are guaranteed that an two interface methods which compile to the same function return the same “type”…. Thus, in this context, interface inconsistency can refer to :
When you implement 2 methods that implement the exact same function, with different side-effects , or diferent underlying assumptions/algorithms that are not expressible in the method signature… i.e. two methods that “look” the same but that “do” different conceptual tasks.
There is also the (non-java specific) GUI connotation, wherein the user experience is confusing, with similar components being utilized for different tasks (or vice-verse, the same task being triggered by different GUI components).
The solution to 1 is to have a more expressive interface, or more precise function names (to exemplify a more sophisticated interface: maybe the Lion and Tiger should provide an Eater object, which is capable of eating in one or more different ways).