[Biojava-l] Private vs Protected

Schreiber, Mark mark.schreiber@agresearch.co.nz
Fri, 3 May 2002 15:47:04 +1200


The general rule is that things should be made as private as possible.
This is for safety to prevent an end user mucking with stuff they
shouldn't. There can be problems however when a poor design leads to
members being made private when they are needed by other classes such as
subclasses.

On the upside private members/ methods can always be made more
accessible (assuming you have the source code). More public things can
NEVER be made less accessible without breaking the API and annoying your
end users.

I think you can extend a class and make a protected thing package or
public. Extending a class does not make private things visible even to
the subclass. One way to make private things visible to the subclass is
to put a protected (or public)  getXXX() method in the base class
(assuming you have code).

Basically if someone has through a lack of foresight not make a method
or member accessible then its best to ignore the fact that its there.
Effectively its not cause you can't see it or change it.

- Mark


> -----Original Message-----
> From: David Waring [mailto:dwaring@u.washington.edu] 
> Sent: Friday, 3 May 2002 3:09 p.m.
> To: biojava
> Subject: [Biojava-l] Private vs Protected
> 
> 
> I have found on several occasions that I would like to extend 
> a class, but variables and methods are private so it is 
> impossible to make use of these in the subclass. Is there a 
> policy about when things should be kept private, and when 
> they should be protected? Is it OK to change this in a base 
> class when extending it?
> 
> David
> 
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org 
> http://biojava.org/mailman/listinfo/biojava-l
> 
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================