Heads up: Mapper<T, R> -> Mapper<R, T>

Henry Jen henry.jen at oracle.com
Tue Nov 6 17:11:24 PST 2012


Agree the naming convention is off-topic, the positional convention is what's more controversial here as developer still need to declare Mapper with type sometimes, and it's counter-intuitive to be result first.

Sure enough we can get used to Yoda-style, but in general I would think of operate(required input, output, optional…) not the other way around.

No matter what EG decided, I +1 Remi on following statement,

> all methods that declares a type parameter used as first parameter of a 
> functional type should also be declared first.

For example, <T, R> Comparators.comparing(Mapper<R, T>) should be changed.

Cheers,
Henry


On Nov 6, 2012, at 4:14 PM, Brian Goetz <brian.goetz at oracle.com> wrote:

> These are the java naming conventions (unless we change them).  
> 
> However, were not going to have that discussion here.  Discussions about naming conventions is completely off topic for this list. 
> 
> Sent from my iPhone
> 
> On Nov 6, 2012, at 6:53 PM, Pablo Grisafi <pablogrisafi1975 at gmail.com> wrote:
> 
>> Can we please abandon the horrible misleading one-letter-for-types convention?
>> Looks like we are in programming in BASIC again
>> Let's use good intention revealing names, please
>> Name<Result, Parameter> or Name<Input, Output> or even Name<TInput,
>> TOutput> are way better than Name<T,R>
>> For one type argument classes, like List<E>, it is not that important,
>> but even in that case, List<Element> is better
>> Sorry if my English is not good enough. Sometimes I think I'm the only
>> average Java programmer reading this list.
>> Am I missing some clever reason why we are using the one-letter convention?
>> 
>> Pablo Grisafi
>> pablogrisafi1975 at gmail.com
>> 
>>> ---------- Forwarded message ----------
>>> From: Paul Benedict <pbenedict at apache.org>
>>> To: Jonathan Gibbons <jonathan.gibbons at oracle.com>
>>> Cc: lambda-dev at openjdk.java.net
>>> Date: Tue, 6 Nov 2012 13:06:03 -0600
>>> Subject: Re: Heads up: Mapper<T, R> -> Mapper<R, T>
>>> Is R and P better than I and O? I don't think I could guess R and P
>>> without
>>> reading the javadoc. I and O, I can (no pun).
>>> 
>>> On Tue, Nov 6, 2012 at 12:59 PM, Jonathan Gibbons <
>>> jonathan.gibbons at oracle.com> wrote:
>>> 
>>>> Can I suggest that we at least try and establish some naming convention
>>>> as well, so that we are not just relying on positional conventions.
>>>> 
>>>> There are already some JDK APIs with "result first, then parameter",
>>>> using the convention   Name<R, P>   R for Result, P for Parameter
>>>> 
>>>> -- Jon
>> 
> 



More information about the lambda-dev mailing list