You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Niall Pemberton <ni...@blueyonder.co.uk> on 2005/11/23 03:23:23 UTC

[resources] Changing instance variables from protected to private

Is there any objection to me changing instance variables from "protected" to
"private"?

Niall



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


Re: [resources] Changing instance variables from protected to private

Posted by Niall Pemberton <ni...@gmail.com>.
On 11/23/05, Martin Cooper <ma...@apache.org> wrote:
> On 11/22/05, Niall Pemberton <ni...@gmail.com> wrote:
> >
> > On 11/23/05, Craig McClanahan <cr...@apache.org> wrote:
> > > On 11/22/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > > >
> > > > Is there any objection to me changing instance variables from
> > "protected"
> > > > to
> > > > "private"?
> > >
> > >
> > > +1 unless there are already subclasses that access such variables from
> > their
> > > superclass ... in which case we should evaluate whether a getter method
> > > might be better.  You can always loosen access rights later, but you
> > can't
> > > put the toothpaste back in the tube.
> >
> > There are only two where this is the case.DatabaseBasicMessages
> > sets/gets the key and values variables inherited from BasicMessage.
> > BasicMessage has getters but no setters, but DatabaseBasicMessages
> > implements setters. Could either leave it as is, or move the setters
> > out of DatabaseBasicMessages and into BasicMessage. For now I'm going
> > to leave it as it is, unless someone shouts.
>
>
> To use Craig's metaphor, this is really another toothpaste in the tube thing
> - if we don't create getters / setters now, we won't be able to do that
> later if we need to, for example if the variable gets moved to a different
> class or the value is derived in some other way.

OK I'll make the changes - I was just trying to be lazy :-)

Niall

> --
> Martin Cooper
>
>
> The other one is the static "factory" variable in Messages - at the
> > moment the only reference is in one of the test classes which sets it,
> > but making it private would mean it can never be changed from
> > ResourcesBundleResourcesFactory without a static setter being added.
> > Again I'm going to leave it as it is, unless someone shouts.
> >
> > > Niall
> > >
> > >
> > > Craig

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


Re: [resources] Changing instance variables from protected to private

Posted by Martin Cooper <ma...@apache.org>.
On 11/22/05, Niall Pemberton <ni...@gmail.com> wrote:
>
> On 11/23/05, Craig McClanahan <cr...@apache.org> wrote:
> > On 11/22/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> > >
> > > Is there any objection to me changing instance variables from
> "protected"
> > > to
> > > "private"?
> >
> >
> > +1 unless there are already subclasses that access such variables from
> their
> > superclass ... in which case we should evaluate whether a getter method
> > might be better.  You can always loosen access rights later, but you
> can't
> > put the toothpaste back in the tube.
>
> There are only two where this is the case.DatabaseBasicMessages
> sets/gets the key and values variables inherited from BasicMessage.
> BasicMessage has getters but no setters, but DatabaseBasicMessages
> implements setters. Could either leave it as is, or move the setters
> out of DatabaseBasicMessages and into BasicMessage. For now I'm going
> to leave it as it is, unless someone shouts.


To use Craig's metaphor, this is really another toothpaste in the tube thing
- if we don't create getters / setters now, we won't be able to do that
later if we need to, for example if the variable gets moved to a different
class or the value is derived in some other way.

--
Martin Cooper


The other one is the static "factory" variable in Messages - at the
> moment the only reference is in one of the test classes which sets it,
> but making it private would mean it can never be changed from
> ResourcesBundleResourcesFactory without a static setter being added.
> Again I'm going to leave it as it is, unless someone shouts.
>
> > Niall
> >
> >
> > Craig
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>

Re: [resources] Changing instance variables from protected to private

Posted by Niall Pemberton <ni...@gmail.com>.
On 11/23/05, Craig McClanahan <cr...@apache.org> wrote:
> On 11/22/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> >
> > Is there any objection to me changing instance variables from "protected"
> > to
> > "private"?
>
>
> +1 unless there are already subclasses that access such variables from their
> superclass ... in which case we should evaluate whether a getter method
> might be better.  You can always loosen access rights later, but you can't
> put the toothpaste back in the tube.

There are only two where this is the case.DatabaseBasicMessages
sets/gets the key and values variables inherited from BasicMessage.
BasicMessage has getters but no setters, but DatabaseBasicMessages
implements setters. Could either leave it as is, or move the setters
out of DatabaseBasicMessages and into BasicMessage. For now I'm going
to leave it as it is, unless someone shouts.

The other one is the static "factory" variable in Messages - at the
moment the only reference is in one of the test classes which sets it,
but making it private would mean it can never be changed from
ResourcesBundleResourcesFactory without a static setter being added.
Again I'm going to leave it as it is, unless someone shouts.

> Niall
>
>
> Craig
>
>

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


Re: [resources] Changing instance variables from protected to private

Posted by Craig McClanahan <cr...@apache.org>.
On 11/22/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
>
> Is there any objection to me changing instance variables from "protected"
> to
> "private"?


+1 unless there are already subclasses that access such variables from their
superclass ... in which case we should evaluate whether a getter method
might be better.  You can always loosen access rights later, but you can't
put the toothpaste back in the tube.

Niall


Craig