[ 
https://issues.apache.org/jira/browse/MATH-348?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841976#action_12841976
 ] 

Ted Dunning commented on MATH-348:
----------------------------------


I agree that the usage should be consistent within a class.  If instance 
variables are used to compute the result, then the class should use only 
instance variables.  If getters are used instead, then they should be used 
everywhere in the class.  

I doubt very seriously that there is any measurable performance.  JIT's are 
very good a converting getters into in-line code.

That means that there are two possible courses of action:

a) avoid getters within a class

b) always use getters

Neither of these would be adversely impacted by sub-classing.  In fact, I can 
imagine that there would be a few cases where it would be very, very useful to 
be able to over-ride the getter in order to force the class to do something 
interesting.  Those probably are corner cases that could be handled by using 
the setters appropriately.



> Indirect access to instance variables
> -------------------------------------
>
>                 Key: MATH-348
>                 URL: https://issues.apache.org/jira/browse/MATH-348
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 2.0
>            Reporter: Gilles
>            Priority: Trivial
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In all the methods (except the setters/getters) of
>   BinomialDistributionImpl
>   CauchyDistributionImpl
>   ExponentialDistributionImpl
>   FDistributionImpl
>   GammaDistributionImpl
>   HypergeometricDistributionImpl
>   TDistributionImpl
>   NormalDistributionImpl
>   WeibullDistributionImpl
>   ZipfDistributionImpl
> the instance variables are accessed through their respective getter.
> This is confusing (and possibly inefficient).
> What would be the expected behaviour of the getter if it were overriden?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to