On 05/03/2010, Gilles Sadowski <gil...@harfang.homelinux.org> wrote:
> Hello.
>
>
>  > 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.

Not necessarily - if it turns out that the field needs to be
synchronized, then always using the getter/setter rather than direct
access makes it very easy to fix the problem.

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

If there is a good reason to override the getter/setter, then it is
likely that the sub-class wants the new value to be used throughout.

>  Best,
>  Gilles
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>  For additional commands, e-mail: dev-h...@commons.apache.org
>
>

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

Reply via email to