Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DFF0CD782 for ; Fri, 17 Aug 2012 11:16:30 +0000 (UTC) Received: (qmail 56648 invoked by uid 500); 17 Aug 2012 11:16:30 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 56483 invoked by uid 500); 17 Aug 2012 11:16:27 -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 56453 invoked by uid 99); 17 Aug 2012 11:16:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 11:16:27 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.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.28] (HELO sif.is.scarlet.be) (193.74.71.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 11:16:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1345202159; bh=w2G4jEpLd1pAEbg/fDDsxq8o8dWli0Mv5f1Mal9Fe1A=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Transfer-Encoding:In-Reply-To; b=22ZDvVQf+b8i3ioK/d7cxhQSqdKizUnyfHXj0AEFvIdoI3b6IPf237gLFnM/qk4di RWwVZMpg8hxBKhAaRWH8zHvgpS+K+hqMZcIOcGomnjmsPjGiDBSkUOaYlvZ1s+nTGs Fk8UJf7KS1V3imI9q9hS6wuzS8rM7EcP9KyFmOGs= Received: from mail.harfang.homelinux.org (ip-62-235-218-104.dsl.scarlet.be [62.235.218.104]) by sif.is.scarlet.be (8.14.5/8.14.5) with ESMTP id q7HBFw4S008186 for ; Fri, 17 Aug 2012 13:15:59 +0200 X-Scarlet: d=1345202159 c=62.235.218.104 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 5D64461B61 for ; Fri, 17 Aug 2012 13:15:58 +0200 (CEST) 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 zQbopfRmtc50 for ; Fri, 17 Aug 2012 13:15:54 +0200 (CEST) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 8EBFA617E4 for ; Fri, 17 Aug 2012 13:15:54 +0200 (CEST) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.77) (envelope-from ) id 1T2KWw-0005wQ-ED for dev@commons.apache.org; Fri, 17 Aug 2012 13:15:54 +0200 Date: Fri, 17 Aug 2012 13:15:53 +0200 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: [Math] Cleanup in "HarmonicFitter" and "GaussianFitter" Message-ID: <20120817111553.GZ20488@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <20120816205806.GL24856@dusk.harfang.homelinux.org> <502DE763.9070505@free.fr> <20120817102457.GY20488@dusk.harfang.homelinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.21 (2010-09-15) X-DCC-scarlet.be-Metrics: sif 20001; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at sif X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Aug 17, 2012 at 11:46:22AM +0100, sebb wrote: > On 17 August 2012 11:24, Gilles Sadowski wrote: > > On Fri, Aug 17, 2012 at 09:40:49AM +0100, sebb wrote: > >> On 17 August 2012 07:40, Luc Maisonobe wrote: > >> > Le 16/08/2012 23:48, sebb a �crit : > >> >> On 16 August 2012 21:58, Gilles Sadowski wrote: > >> >>> Hello. > >> >>> > >> >>> In classes "HarmonicFitter" and "GaussianFitter" (in package > >> >>> "o.a.c.m.optimization.fitting"), there is an inner class "ParameterGuesser". > >> >>> All the necessary input for the guessing procedure is passed to the > >> >>> constructor; I thus propose that the guessing is performed at object > >> >>> construction rather than at the call to the "guess()" method. This will > >> >>> allow to declare all the fields "final". Moreover, all that can go wrong > >> >>> will be located in the constructor, turning the "guess" method into a mere > >> >>> accessor. > >> > > >> > +1 to Gilles suggestion. > >> > > >> >> > >> >> On the face of it, it sounds like the class does not even need to be > >> >> instantiated. > >> >> Could the guess method be turned into a static utility method to which > >> >> the parameters are passed? > >> >> Why bother creating an instance only to return the guess later? > >> > > >> > It could be. There are a bunch of methods involved and they exchange > >> > data which is now stored in a few class fields (observation arrays and > >> > the three estimated parameters), so these data should be added as > >> > parameters to the static functions. > >> > > >> > I'm not sure whether it is cleaner to have a small instance created for > >> > a short time to perform some difficult preprocessing or to have a bunch > >> > of static methods. > >> > >> Instances need to be disposed of by GC whereas parameters > >> automatically disappear when a called procedure returns. > > > > As a short-lived object, I guess that performance will not be improved > > greatly (especially w.r.t. the time taken for the fitting itself). > > > >> A class with no fields is guaranteed immutable. > > > > The class will be immutable. > > > >> > >> But for large numbers of parameters, class data is perhaps cleaner. > > > > Being "public", the inner class cannot disappear now; so I'll do the first > > cleanup, and we'll see later if further changes are in order. > > Is the class directly usable by 3rd parties? Yes. > Would it make sense for a 3rd party to use it directly? Maybe. They could compare the guessed values with the optimized ones. Admittingly, this is not very useful... if everything works fine. > > If not, then although it would break strict binary compat., it would > be possible to consider changing it. > If it's not directly used by 3rd party code, I don't think changes can > break their code. I don't understand: the class is public. Someone can have instantiated it in his code... > > Ideally any such helper classes should be private or package protected > ab initio. I agree. However in this case, the boundary between helper and utility (that could be useful on its own) is not clear-cut. Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org