Community
Participate
Working Groups
Build Identifier: 20110218-0911 There are several situations when people by mistake use concrete classes where interface should be used: // Using concrete class to the left of the assignment ArrayList<String> a = new ArrayList<String>(); // Using concrete class into the generics new ArrayList<ArrayList<String>> // Using concrete class as an method parameter or return type HashSet<Integer> foo(ArrayList<String> list){} Probably more complicated case is when people use "wrong" interface, e.g. List<String> list = new ArrayList<String>(); for (String s : list) {/*do somthing*/} List is not needed here. Collection is enough: Collection<String> list = new ArrayList<String>(); for (String s : list) {/*do somthing*/} I think that it could be a good feature if IDE can produce such types of warnings. It can help people to write better and more reusable code. This link provides additional details and an attempt to solve the problem using regular expressions: http://alexradzin.blogspot.com/2011/07/find-bad-coding-practices-using-regular.html Reproducible: Always