On 11/6/11 11:44 PM, in article
16628826.552.1320619468157.JavaMail.geo-discussion-forums@prlm15, "Lew"
<lewbloch@gmail.com> wrote:
I really enjoy the improvement in code readability as well, it suits the
appropriate template types e.g.
// from
List<RequestData> requests = new ArrayList<RequestData>();
// to
List<RequestData> 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<RequestData> requests = new ArrayList<RequestData>();
// making the problem more explicit ...
List<Map<TpchWorkload,Map<String,List<Object>>>> parameters = new
ArrayList<Map<TpchWorkload,Map<String,List<Object>>>>();
// simply beautiful
List<Map<TpchWorkload,Map<String,List<Object>>>> 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!
That particular argument is somewhat obsolete with Java 1.7.
programming, but that is a different discussion.