From dev-return-23271-apmail-jackrabbit-dev-archive=jackrabbit.apache.org@jackrabbit.apache.org Mon May 04 21:28:38 2009 Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 73471 invoked from network); 4 May 2009 21:28:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 May 2009 21:28:38 -0000 Received: (qmail 89231 invoked by uid 500); 4 May 2009 21:28:37 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 89173 invoked by uid 500); 4 May 2009 21:28:37 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 89165 invoked by uid 99); 4 May 2009 21:28:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 May 2009 21:28:37 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tripod@day.com designates 207.126.148.181 as permitted sender) Received: from [207.126.148.181] (HELO eu3sys201aog001.obsmtp.com) (207.126.148.181) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 04 May 2009 21:28:28 +0000 Received: from source ([209.85.218.215]) by eu3sys201aob001.postini.com ([207.126.154.11]) with SMTP ID DSNKSf9d596CPJDC04qnb1g1CK3ZzSb8dG01@postini.com; Mon, 04 May 2009 21:28:08 UTC Received: by bwz11 with SMTP id 11so4383999bwz.25 for ; Mon, 04 May 2009 14:28:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.113.198 with SMTP id b6mr6136955bkq.108.1241472487501; Mon, 04 May 2009 14:28:07 -0700 (PDT) In-Reply-To: <49FEF7B4.2090306@gmail.com> References: <91f3b2650905040617w57e838c8y106809810c6aaa82@mail.gmail.com> <49FEF7B4.2090306@gmail.com> Date: Mon, 4 May 2009 23:28:07 +0200 Message-ID: Subject: Re: Generics generator class From: Tobias Bocanegra To: dev@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, May 4, 2009 at 4:12 PM, Felix Meschberger wrot= e: > Hi, > > Thomas M=FCller schrieb: >> Hi, >> >> I would like to use Java 1.5 features now in Jackrabbit. I hope this >> will improve reliability, simplify maintenance, and reduce source code >> size. Unfortunately using generics is sometimes quite verbose. > > I don't consider this a big issue. > >> Example: >> >> HashMap wspInfos =3D new HashMap(); >> becomes >> HashMap wspInfos =3D new HashMap(); >> >> Part of that could be avoided using a helper class: >> >> HashMap wspInfos =3D New.hashMap(); >> >> I propose to add a new 'generics generator class' called 'New' to >> jackrabbit-jcr-commons. It would contain constructor methods for the >> most commonly used collection objects. >> >> public class New { >> =A0 =A0 public static HashMap hashMap() { >> =A0 =A0 =A0 =A0 return new HashMap(); >> =A0 =A0 } >> =A0 =A0 public static ArrayList arrayList() { >> =A0 =A0 =A0 =A0 return new ArrayList(); >> =A0 =A0 } >> =A0 =A0 public static WeakReference weakReference(T t) { >> =A0 =A0 =A0 =A0 return new WeakReference(t); >> =A0 =A0 } >> =A0 =A0 ... >> } >> >> What do you think? Are there better solutions? > > -1 > > Starting to have such helper classes amounts to a spiral with no end. > There is IMHO also no use. i agree with felix. such helper classes only confuse developers and do not really have a big advantage. i like it to be verbose - it easier to read, since you know what you get, and simpler to debug. furthermore it creates a new dependency to another package. so: -1 for adding a 'New' helper class. regards, toby > > In fact, while the "new HashMap()" construct has > almost no influence on the generated class file, the helper class > creates a new class object and increases memory footprint. I think the > price is beyond what might be acceptable. > > Regards > Felix > > >> >> Regards, >> Thomas >> > >