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

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

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


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.


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

Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
    [ 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.


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

Posted by "Ted Dunning (JIRA)" <ji...@apache.org>.
    [ 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.


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

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz closed MATH-348.
----------------------------


> 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
>             Fix For: 2.1
>
>   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.


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

Posted by "Gilles (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gilles updated MATH-348:
------------------------

    Description: 
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?


  was:
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?



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


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

Posted by "Gilles (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gilles resolved MATH-348.
-------------------------

       Resolution: Fixed
    Fix Version/s: 2.1

Issue is fixed in revision 920852.
Setters were marked as deprecated.


> 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
>             Fix For: 2.1
>
>   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.