There it goes a design issue I've been thinking about for, without finding convincing info about it.
Supposing I've got some instance variables into my classes, now imagine I want to write some private functionality for my class, using that value. It's not a problem to write something like that:
public class Example{
private String attribute1;
public void setAttribute1(String att){
this.attribute1 = att;
}
private void processAttribute(){
//do something with attribute1
}
public void executeExample(){
processAttribute();
}
}
Where processAttribute()
uses the attribute1
value internally. However, many doc says we should try to limit the use of global variables. Would it be a more reusable and well-designed way to write something like this?
public class Example{
private String attribute1;
public void setAttribute1(String att){
this.attribute1 = att;
}
private void processAttribute(String att){
//do something with attribute1
}
public void executeExample(){
processAttribute(this.attribute1);
}
}
Pool your ideas.