Hi.
Let's say I've got a type called Superstar
. Now I want to have a method that does some work and edits some properties of a Superstar
object.
Here are two ways of how I could implement this. Way 1 would be the following:
private Superstar editSuperstar(Superstar superstar){
....
superstar.setEdited(true);
return superstar;
}
...
superstar = editSuperstar(superstar);
And way 2 would be this:
private void editSuperstar(Superstar superstar){
....
superstar.setEdited(true);
}
...
editSuperstar(superstar);
Which one of these two possible ways is considered "best practice"? The first one, or the second pseudo "by reference" one?