commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <p...@steitz.com>
Subject [math] caching factory / object instances
Date Sat, 05 Jun 2004 23:07:51 GMT
Currently, we have code like the following at various places in [math]
TDistribution tDistribution =
DistributionFactory.newInstance().createTDistribution(degreesOfFreedom);

Ken Geis pointed out that at least the way newInstance() is implemented 
now, this is expensive and inefficient 
(http://nagoya.apache.org/eyebrowse/BrowseList?listName=commons-dev@jakarta.apache.org&by=thread&from=766928).

  One way to solve the immediate problem would be to have the enclosing 
class (e.g. TTestImpl) cache the factory instance (or even the 
distribution instance).  A better solution might be to have 
DistributionFactory do the caching and expose a getInstance() method.  I 
think Stephen suggested something like this in his API review.

I opened a bug report 
(http://issues.apache.org/bugzilla/show_bug.cgi?id=29068) to track this 
issue and I would like to address it consistently throughout [math]. Are 
there any objections to replacing the XxFactory.newInstance() methods with 
getInstance() methods that return cached instances?  Is there any reason 
that we should *not* do this?

Phil


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message