Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 79717 invoked from network); 5 Mar 2010 21:55:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Mar 2010 21:55:48 -0000 Received: (qmail 79952 invoked by uid 500); 5 Mar 2010 21:55:33 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 79831 invoked by uid 500); 5 Mar 2010 21:55:33 -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 79823 invoked by uid 99); 5 Mar 2010 21:55:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Mar 2010 21:55:32 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [193.74.71.27] (HELO eir.is.scarlet.be) (193.74.71.27) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Mar 2010 21:55:28 +0000 Received: from mail.harfang.homelinux.org (ip-62-235-218-76.dsl.scarlet.be [62.235.218.76]) by eir.is.scarlet.be (8.14.2/8.14.2) with ESMTP id o25Lt67O004631 for ; Fri, 5 Mar 2010 22:55:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=scarlet.be; s=scarlet; t=1267826106; bh=t+N4XVhPdskDg2xSzUIjMrZRTSVS8hjCLCsJxq3iuJM=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=Q3B8ykNgwgTYMVWz8PZsUj5gTSx3nIV6jj5d8Y3FvirlQyFd75tpEuo4CW2vpP0UP 4uEuNSev4j4jCxTJll93mXc1sN45uykZeayGL0mDDzUj5oOw/JV7NZ8y9Pl1eXT8ie g51EJi+ekM2lHitZD+gnxHAQDLR77oxp/B9DSLhM= Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 55B70617EE for ; Fri, 5 Mar 2010 22:56:12 +0100 (CET) Received: from mail.harfang.homelinux.org ([192.168.20.11]) by localhost (mail.harfang.homelinux.org [192.168.20.11]) (amavisd-new, port 10024) with ESMTP id ZbX7Dt7DN-ya for ; Fri, 5 Mar 2010 22:56:10 +0100 (CET) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id A9870617D2 for ; Fri, 5 Mar 2010 22:56:10 +0100 (CET) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.69) (envelope-from ) id 1NnfVC-00085M-Fd for dev@commons.apache.org; Fri, 05 Mar 2010 22:56:10 +0100 Date: Fri, 5 Mar 2010 22:56:09 +0100 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: [Math] Issue 348 Message-ID: <20100305215609.GC6536@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <20100305123427.GD31457@dusk.harfang.homelinux.org> <20100305183716.GB6536@dusk.harfang.homelinux.org> <25aac9fc1003051258t521498d0v409f2b7224cfa4ee@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25aac9fc1003051258t521498d0v409f2b7224cfa4ee@mail.gmail.com> X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.20 (2009-06-14) X-DCC-scarlet.be-Metrics: eir 20002; Body=1 Fuz1=1 Fuz2=1 Hi. > > > I don't see any changes proposed. > > > > > > I propose to use the instance variable in place of the accessor. > > > > > > > I see a couple of statements that getters are used (usually considered > > > good), and a question about over-riding. > > > > > > Getters are for accessing to encapsulated data. Within the class itself the > > data is readily accessible, so using the accessor is, at best, less > > efficient. > > Not necessarily - if it turns out that the field needs to be > synchronized, then always using the getter/setter rather than direct > access makes it very easy to fix the problem. As I note in https://issues.apache.org/jira/browse/MATH-349 you cannot always use the getters/setters, namely in contructors. I don't have a broad view of CM yet, but in principle I'd think it's better to avoid synchronization at the CM level, and rather push toward immutability. E.g. do we loose performance significantly if we have to instantiate a new "NormalDistributionImpl" for each combination of "mean" and "sigma" instead of calling "setMean(m)" and "setStandardDeviation(s)" on an exisitng object? [A few months ago, people here convinced me that we don't, in the case of "Vector3D".] > > Moreover, if, by mistake, a sub-class overrides the accessor, you can get > > inconsistent result: the overridden accessor can return some value while it > > is another (the one stored in the instance variable) that is used to perform > > the calculation. > > If there is a good reason to override the getter/setter, then it is > likely that the sub-class wants the new value to be used throughout. Can you imagine a not contrived example? I.e. why would one inherit from a class while throwing away the implementation? Best, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org