by mmatants · 10y ago · 0 comments
`List<String> a = new ArrayList<String>();`
I know that for some things it is convenient, but I appreciate the reminder to treat interface and implementation as distinct concepts.
But i see where you come from, it feels a bit sloppy to not document the intention that the variable _could_ be any kind of list, even though it happens to be an ArrayList. Not "this may lead to nasty bugs"-sloppy, but a slight case of "this won't win any beauty contests"-sloppy.
If your method bodies are so large that you need to be coding to interfaces within them (as opposed to just setting the return type of your method to the interface), the you've got other problems.