This title is a bit complicated ... When I write an interface, is it better to use the most specific interface at all, or the least?
For example, suppose that
interface List2<T> extends List<T>
{
List<T> getRange(int startIndex, int endIndex);
}
It would be better to change it to
interface List2<T> extends List<T>
{
List2<T> getRange(int startIndex, int endIndex);
}
so that callers can call getRangeby their result, but still match List is polymorphic?
source
share