On Jan 7, 2009, at 5:14 PM, Henning Schmiedehausen wrote:

I  -1 this patch unless you can sufficiently explain why e.g.

-    tokenData = new HashMap<String, String>(5,1);
+    tokenData = Maps.newHashMapWithExpectedSize(5);

is better readable to someone with knowledge of the standard Java APIs
and no knowledge of Google Collections.

Is it really that hard to understand? Really? Some Junior Devs looked at that code and easily understood the intent.

All that this huge patch IMHO does is making the code harder to read
for no particular reasons.

There are reasons. In this case you use the factory methods to not repeat yourself. Consider the degenerate case:

Map<Integer, List<Map<Foo,Bar>>> = new HashMap<Integer,List<Map<Foo,Bar>>>(5,1);

you can replace the RHS with Maps.newHashMapWithExpectedSize(5)

Supposedly in Java 7 you'll be able to use new HashMap<>() instead.. Until then you can use google collections in Java 5 on up.

And that's just scratching the surface. The real power is actually in the Immutable* collection classes, contracts with Preconditions, filtering/transforming with functional features and.. It's also miles better than commons-collections.

Please back the patch out again and let's discuss whether it makes sense.

This code has been in trunk for weeks now, it's only recently been merged to 1.0.x. No one other than yourself has objected. I'd like to get others to weigh in before we start ripping things apart.

IMO life's too short to code everything to base JDK, and we're not exposing any of the google collection classes via the SPI and it's as grokable as any of the umpteen other libs we're depending on to build this product.



Paul Lindner
[email protected]



Reply via email to