I believe that it's better to code to interfaces instead of implementations. In Java:
List<User> users = new ArrayList<User>();
There's no need to specify the runtime type of users
all over the program if the code only cares that it implements List
.
However, I encounter many people who believe that it's totally fine, even when they're not using properties specific to the ArrayList:
ArrayList<User> users = new ArrayList<User>();
I try to explain that it's redundancy and makes the program harder to change, but they don't seem to care. Are there other reasons that this is important? Or perhaps my convictions are overstated?