You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ted Dunning (JIRA)" <ji...@apache.org> on 2010/03/05 19:56:27 UTC

[jira] Commented: (MATH-348) Indirect access to instance variables

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

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

Gilles said in email:
{quote}
> 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.
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.
{quote}

> 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.