What do you expect from the interface?
05 May 2009
Read a great article today - Liskov Substitution Principle (LSP). It let me understand that Interface is not just a list of methods.Let's review the following utility function:
public static void processList(List list) {
list.clear();
list.add(new Object());
}
But does the result really meet your expectation? Who knows, the object that implements list interface do not guarantee you 'Act as container' behavior. It just implements all the methods of the interface and nothing else.
Actually all methods of the interface
Idea: Maybe one day programming languages will have unit tests as part of interface and validate each instance that implements this interface with them.