uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Kottmann <kottm...@gmail.com>
Subject Re: generics: getViewIterator
Date Wed, 12 Aug 2009 23:34:36 GMT
Marshall Schor wrote:
> Sounds right.  But we should use bounded wildcards for "arguments" where
> appropriate (of course, this doesn't apply to getViewIterator, which has
> no arguments).  The article,
>
> http://www.ibm.com/developerworks/java/library/j-jtp07018.html?S_TACT=105AGX02&S_CMP=EDU
> has a nice "principle" called the "get-put" principle for arguments:
>
>     Use an |extends| wildcard when you only get values out of
>     a structure, use a |super| wildcard when you only put values
>     into a structure, and don't use a wildcard when you do both.
>
> For the last part, he also says the reason for not using a wild card if you do both:
>     If you can put a |T| or any of its subtypes, and you can get a |T| or any of its
supertypes, then the only thing you can both get and
>     put is a |T| itself.
>
>   
Well, I was aware of the get part, but it does not always makes sense, 
in my eyes,
e.g. when a method receives a List<String> from somewhere.
I never used the put part of the rule, which may indicate I did 
something wrong
in a very few places, because output Lists for example are rarely used.

Jörn

Mime
View raw message