Like Allen before , my advice comes more from C # (which I have been using widely since 5 months) than Java (with which I played, but it never went very far ...), but I find Java and C # code very similar in spirit (that is, when compared, say, with C ++)
Anyway, when using C # / Java generic (or the C ++ template) on a simple type, I usually use T:
// C++ template<typename T> class MyClass { /* ... */ } ; // C# public MyClass<T> { /* etc. */ } // Java public MyClass<T> { /* etc. */ }
Typically, type T comes with a class, so there is no need to describe it anymore.
But when a really descriptive type adds clarity to the code, I do it.
Or when I have two or more types in the same generic / template declaration, this helps to make the difference between the two types. For example (real life example in C #):
// C++ template<typename T_Data, typename T_Underlying> class MyClass { /* ... */ } ; // C# public MyClass<T_Data, T_Underlying> { /* etc. */ } // Java public MyClass<T_Data, T_Underlying> { /* etc. */ }
Thus, it is easy to make a difference between the two names in the code, where T and U , well ... kinda anonymous: for those who use Visual C ++, there is debugging inside the Dinkumware STL code, full T , _U , and other one-letter types Names can be quite annoying ... I think this applies to C # or Java code.
You will notice that in each case (C ++, Java or C #) I do not comply with the agreement somewhere in team applications: The reason is that sometimes you just need to try something else instead of following the herd , even if, in the end, you find yourself wrong.
In this case, violation of the naming convention is not critical (Java has worse problems than this petty crime), and finally, you will find out personally and for sure WHY this is wrong, instead of quoting old documents.
And if you find in the end, you're right, well ...