Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 71308 invoked from network); 30 Sep 2003 20:02:06 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 30 Sep 2003 20:02:06 -0000 Received: (qmail 85964 invoked by uid 500); 30 Sep 2003 20:01:51 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 85753 invoked by uid 500); 30 Sep 2003 20:01:49 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 85728 invoked from network); 30 Sep 2003 20:01:48 -0000 Received: from unknown (HELO carbon.btinternet.com) (194.73.73.92) by daedalus.apache.org with SMTP; 30 Sep 2003 20:01:48 -0000 Received: from host81-128-101-86.in-addr.btopenworld.com ([81.128.101.86] helo=oemcomputer) by carbon.btinternet.com with smtp (Exim 3.22 #23) id 1A4Qgy-0002lT-00 for commons-user@jakarta.apache.org; Tue, 30 Sep 2003 21:01:52 +0100 Message-ID: <011101c3878e$3edecb00$56658051@oemcomputer> From: "Stephen Colebourne" To: "Jakarta Commons Users List" References: <78126560350C524BB0AB6E92BD71E87E17C3CD@dbnms01.oldfort.co.za> Subject: Re: [lang] Reusable Builder classes Date: Tue, 30 Sep 2003 21:02:44 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Possible I suppose. I guess I don't have strong views either for or against. Any other [lang] committers have any views? Stephen ----- Original Message ----- From: "Don Forbes" I find the Builder classes really helpful, but find it wasteful having to create a new HashCodeBuilder, CompareToBuilder or EqualsBuilder for each invocation of a hashCode, equals or compareTo method. In some situations, such as a sort of a large collection, these methods can end up being called often, thus imposing a high garbage collection overhead. I am thinking of something analogous to StringBuffer, which can be reset for reuse by simply calling setLength(0). How about a simple reset() method, with no parameters, that just resets the internal state (e.g. the variable "comparison" in the case of CompareToBuilder) to its initial value? (Possibly also a getter to determine whether the builder is currently in a reusable state.) Granted, this would require the Builder to be an instance variable of the calling object rather than a local variable, thus raising issues of thread safety. Unfortunately using sychronized methods has something of a bad name for performance. In my understanding and experience this is an unfair reputation, and my guess is that the overhead would be amply compensated for by the savings in garbage collection. But short of this, provided the caller is given the responsibility for synchronising access to the object in a multithreading scenario, I don't see a problem. Any thoughts? Don --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.515 / Virus Database: 313 - Release Date: 2003/09/01 --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org