|
I guess that protected valiable could be useful when you do not want to
expose it in public interface, but want to allow access to these variables
from subclasses...
Yakov,
protected org.apache.commons.logging.Log log;
public static String DATA_DIR_PROPERTY="data.dir";
private org.w3c.dom.Document doc = null;
protected GenericTestCase( String name ) {
Class c = this.getClass();
log = org.apache.commons.logging.LogFactory.getLog ( c );
}
protected void setDocument (Class c){
...
}
protected org.w3c.dom.Document getDocument() { return doc; }
protected String getTestFieldStringFromCDATA(String fieldName, org.w3c.dom.Node testNode) throws Exception {
...
}
protected String getTestFieldString(String fieldName , org.w3c.dom.Node testNode ) {
...
}
protected Object[] getTestFieldArray ( String fieldName, org.w3c.dom.Node testNode) throws Exception {
...
}
Would it be bad it your GenericTestCase had the variable log private and a
public getLog() method?
You've asked yourself if anyone else would need use getTestField, and
answered negative. Do you even have aske yourself this question?
Yakov,
Lunch is fine, but during lunch I'd rather talk about food, travel, wine,
beer and women than about use of protected variables :)
Yakov,
Sorry Michael, it did not help.
I meant that defining "protected" vs. public is just a concise way to
communicate a message: