commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject [lang] Pair names still not right or consistent
Date Wed, 04 May 2011 16:58:10 GMT
Hi All:

I think we still have naming problems with the Pair class reflected in this
Javadoc fragment:

 * @param <L> the first element type
 * @param <R> the second element type

Either we call them L left and R right, or we call them F first and S
second, but mixing both is not good IMO.

My preference is for K key and V value.

I still do not like Pair as a name because a pair is: two identical,
similar, or corresponding things that are matched for use together: a pair
of gloves; a pair of earrings.
(http://dictionary.reference.com/browse/pair)

We clearly break this common sense definition.

Tuple is better, Association is better (if wordier.)

Why is Pair a good name?

Writing Pair.of(lastName, address) reads ugly and wrong to me. It feels like
I am writing a bug or using the API incorrectly.

The association, correspondence, tuple, whatever you call it, of these two
values is just not a pair of anything. Anything but java.lang.Object... but
that's not even true since null is not an Object.

-- 
Thank you,
Gary

http://garygregory.wordpress.com/
http://garygregory.com/
http://people.apache.org/~ggregory/
http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message