In general I try to avoid using raw types in the signature of methods in the libraries I develop. However, lately I am starting to relax this (self-adopted) rule-of-thumb, and I am starting to write raw types more often than before.
For example, assuming a method receiving any list as parameter (i.e., the type of the list members is not important), I was tempted before to declare it as:
void myMethod(List<?> list) {...}
But now I am starting to write more and more:
void myMethod(List list) {...}
Because it is shorter.
My concrete question is: In the scenario where type parameters are not important, is using raw types in method parameters considered a good practice ? If not, why not ?
The only problem I see is being condemned to see an eternal warning in the IDE I use (although probably that can be deactivated somewhere), but I would like to be sure I am not missing something else.
Update:
Got fully convinced I should use generics everywhere after reading the paragraph below here:
Use of raw types is discouraged. The Java Language Specification even states that it is possible that future versions of the Java programming language will disallow the use of raw types.
List<?>
orvoid <T> myMethod(List<T> list)
to avoid the raw type