Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Giovanni Azua Newsgroups: comp.lang.java.programmer Subject: Re: Immutable Datastructures with good Sharing Date: Mon, 07 Nov 2011 01:28:35 +0100 Lines: 45 Message-ID: References: <16628826.552.1320619468157.JavaMail.geo-discussion-forums@prlm15> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net fXG3FHIGeREYTKkN3M/zgwStmK4xilC3LLdiyEp7C1av1MWFnX Cancel-Lock: sha1:1KsnR3FfZIqRhR2j/IOc4NVqnsw= User-Agent: Microsoft-Entourage/12.31.0.110725 Thread-Topic: Immutable Datastructures with good Sharing Thread-Index: Acyc5C97q9NRR08rB0qoHq7MWqXoEA== Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9705 Hi Lew, On 11/6/11 11:44 PM, in article 16628826.552.1320619468157.JavaMail.geo-discussion-forums@prlm15, "Lew" wrote: >> I really enjoy the improvement in code readability as well, it suits the >> appropriate template types e.g. >> >> // from >> List requests = new ArrayList(); >> >> // to >> List requests = Lists.newArrayList(); >> > > I'm not saying anything against Guava, but I fail to see the advantage of that > particular idiom. 'Lists.newArrayList' vs. 'new ArrayList<>' - eh, mezza > mezz'. > I don't blame you. I had the same resistant first reaction when I was proposed to use Guava. Then something magical happened :) I realized that when you use new with Collections, generally you have to tell the compiler two times what you want namely the generic parameter. I think that having to do the same thing two times in development is always a bad thing: two times harder to maintain, two times the amount of possible mistakes and in short, two times the amount of work. // two times having to type RequestData ... no big deal List requests = new ArrayList(); // making the problem more explicit ... List>>> parameters = new ArrayList>>>(); // simply beautiful List>>> parameters = Lists.newArrayList(); Now tell me, how much time have you spent in your life fixing the small mistakes that originate from getting the LHS out of sync with the RHS? This alone is one of those small details that make your daily development work enjoyable rather than painful. Guava rocks!