Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 55014 invoked from network); 29 Jul 2008 18:50:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jul 2008 18:50:20 -0000 Received: (qmail 64563 invoked by uid 500); 29 Jul 2008 18:50:18 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 64483 invoked by uid 500); 29 Jul 2008 18:50:17 -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 64472 invoked by uid 99); 29 Jul 2008 18:50:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2008 11:50:17 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [80.12.242.95] (HELO smtp27.orange.fr) (80.12.242.95) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jul 2008 18:49:22 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2711.orange.fr (SMTP Server) with ESMTP id F16381C0009F for ; Tue, 29 Jul 2008 20:49:36 +0200 (CEST) Received: from lehrin (AToulouse-256-1-129-115.w90-45.abo.wanadoo.fr [90.45.56.115]) by mwinf2711.orange.fr (SMTP Server) with ESMTP id B0E751C00087 for ; Tue, 29 Jul 2008 20:49:36 +0200 (CEST) X-ME-UUID: 20080729184936724.B0E751C00087@mwinf2711.orange.fr Received: from [127.0.0.1] (localhost [127.0.0.1]) by lehrin (Postfix) with ESMTP id 31A324063 for ; Tue, 29 Jul 2008 20:49:36 +0200 (CEST) Message-ID: <488F6640.5070501@free.fr> Date: Tue, 29 Jul 2008 20:49:36 +0200 From: Luc Maisonobe User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Commons Developers List Subject: Re: [math] formatting composite objects References: <488AE9D3.40103@free.fr> <488CC999.8050707@gmail.com> In-Reply-To: X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Brent Worden a �crit : > The getInstance() method can not return a sole instance because the > default locale can change via java.util.Locale#setDefault > > The purpose of the format setters is to provide similar behavior as > found on java.text.NumberFormat with the ability to modify formatting > parameters. They provide a convenience to having several methods to > alter the parameters for each of the number parts. > > I would not be in favor of making the type immutable because it is > contrary to the design of the standard Format types. This explanation is fine for me. I will not implement the changes I suggested. By the way, the changes I implemented a few days ago were not related to this: they were simply for the sake of extracting the CompositeFormat superclass. Thanks Luc > > On Sun, Jul 27, 2008 at 2:16 PM, Phil Steitz wrote: >> Luc Maisonobe wrote: >>> Hello, >>> >>> I am writing a new Vector3DFormat class in the spirit of the >>> ComplexFormat class for input/output. >>> >>> Since some parts are common (parsing one component, handling locales), I >>> have extracted a CompositeFormat base class from ComplexFormat and will >>> use it as the base class for Vector3D and perhaps for future other >>> classes. >>> >>> I see that the current ComplexFormat class provides two getInstance() >>> static methods whose javadoc is: "Returns the default complex format for >>> the current locale". The instance returned is *not* a singleton, it is >>> rebuilt each time but the javadoc doesn't says it. Since the class is >>> not immutable (there are set methods), it may lead to surprising results >>> to users. >>> >>> I see two options here: >>> 1) We keep a mutable class, and either we replace the two getInstance() >>> static methods by constructors or we rename them createInstance() >>> 2) We change the class to immutable and we remove the set methods >>> >>> My preference is 2). I don't like mutable objects, especially for a low >>> level library which can be reused differently from various other middle >>> level libraries and directly by users. Each part of the code should know >>> exactly what the instances it uses do, and either use the default one >>> provided by getInstance for general purpose, being sure nobody with >>> change its settings under the hood or use a specific instance with >>> custom settings. >>> >>> What do you think about it ? >>> >> I agree with you on the name change s/get/create or "new" but I think users >> of ComplexFormat need to be able to pass in formats, so the factory itself >> either needs to be mutable or have these things in constructors. In theory, >> someone might want to use the setters; though I can't think of a real world >> use case. The problem with the name change is backward compatibility. I >> would be +1 for deprecation and introducing "create" or "new" methods. >> >> Base CompositeFormat class looks good. >> >> Phil >>> Luc >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org