Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 29946 invoked from network); 11 Apr 2011 20:25:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Apr 2011 20:25:26 -0000 Received: (qmail 95993 invoked by uid 500); 11 Apr 2011 20:25:26 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 95909 invoked by uid 500); 11 Apr 2011 20:25:26 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 95901 invoked by uid 99); 11 Apr 2011 20:25:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2011 20:25:26 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gudnabrsam@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-wy0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2011 20:25:21 +0000 Received: by wyb32 with SMTP id 32so5697517wyb.30 for ; Mon, 11 Apr 2011 13:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=IrWYEggC834oD/Laakl5wHJcbkeA/zP1iTTt6gPavYU=; b=rZ5ebEWE9C1Ux3EoJZ/YEsH8jX2LtFdtGN2UG+6VhrpxiTs7tt/ZB+72AluNUr6lQH eu9abGte8OoQN4NNErrWuoKUKMazUEF9SwMqN79AnF0yGyeQ3zCdBst07SE5CdDGLJH7 0+CRk3cp69GHgFC2WhViW/ipcXExHvEoZCuTI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; b=AifO+A9jDqZHdIAIucumI8HgnMecLTPApmjaiAZsnLDWqW1NgE3IEOwWz5ZdRFdEsY 3j23SfsU360LpjuvOANF0Sg6+Y22xm9MLLVbiW8qUk0wO8d3gQntACUc//slYYPjcAhq NB6HTf7GIPXsSqhKxx4uncwMJHiH9pxHYhUoE= MIME-Version: 1.0 Received: by 10.216.243.138 with SMTP id k10mr3116599wer.104.1302553500282; Mon, 11 Apr 2011 13:25:00 -0700 (PDT) Received: by 10.216.158.70 with HTTP; Mon, 11 Apr 2011 13:25:00 -0700 (PDT) Reply-To: gudnabrsam@gmail.com In-Reply-To: References: Date: Mon, 11 Apr 2011 15:25:00 -0500 Message-ID: Subject: Re: [Lang] Pair toString From: Matt Benson To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 11, 2011 at 1:17 PM, Gary Gregory wrote: > On Mon, Apr 11, 2011 at 2:14 PM, Gary Gregory wrote: > >> On Mon, Apr 11, 2011 at 1:52 PM, Stephen Colebourne wrote: >> >>> I fixed the Map.Entry equals/hashCode compliance. >>> >>> I shortened the toString form to omit the class name, as it is >>> superfluous -> (A,B) >>> >>> Out library uses square brackets, but I can live with round. >>> >>> I don't believe that requiring every pair to carry around a format >>> string is viable. These must be small objects. I could live with a >>> toString(format) variation if that would help. >>> >>> I also believe that getLeftElement()/getRightElement() are too long. >>> They should be getLeft()/getRight(). >>> >> >> +1, "Element" does not add value (worse would be "Object"). >> > > I've done the rename locally and it reads much better in the code. Good > suggestion Stephen :) I'll let it site for a little while and commit unless > tomatoes start flying. > I very much like the field accessors left/right. getLeft()/getRight() sounded a little strange to me, hence the -Element naming (I agree -Object would have been worse, hence my choice of element, which I also feel conveys the suggestion of "tupleness"). If the majority feels getLeft()/getRight() are more palatable, I won't fight it. I suppose bean property conventions make getLeft()/getRight() preferable to left()/right(), despite the fact that there seems to be no conflict between these ultra-short method names and their public final ImmutablePair.* field analogues. Matt > Gary > >> >> I do not like the class name either as I've wrote in another thread: a pair >> of objects IMO are similar, and I often associate objects together that are >> not a "pair" in the traditional sense ("a pair of shoes") but that are an >> association like a key and a value. This is why I use the Smalltalk old >> school class name of Association in our version at work. >> >> Gary >> >> >>> I'd also prefer to make the ImmuatblePair final. >>> >>> Stephen >>> >>> >>> On 11 April 2011 15:00, Gary Gregory wrote: >>> > Hi All: >>> > >>> > I added a test to verify the default Pair toString behavior. >>> > >>> > For me to replace our custom Pair class at work, I need to customize the >>> to >>> > String behavior. >>> > >>> > Subclassing ImmutablePair and MutablePair to override toString smells >>> nasty. >>> > >>> > What about adding a formatString ivar which will be used with the >>> > String.format API? >>> > >>> > -- >>> > Thank you, >>> > Gary >>> > >>> > http://garygregory.wordpress.com/ >>> > http://garygregory.com/ >>> > http://people.apache.org/~ggregory/ >>> > http://twitter.com/GaryGregory >>> > >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> >> >> >> -- >> Thank you, >> Gary >> >> http://garygregory.wordpress.com/ >> http://garygregory.com/ >> http://people.apache.org/~ggregory/ >> http://twitter.com/GaryGregory >> > > > > -- > Thank you, > Gary > > http://garygregory.wordpress.com/ > http://garygregory.com/ > http://people.apache.org/~ggregory/ > http://twitter.com/GaryGregory > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org