Hello again,
Since I learned about classes and their internal reference this, I wondered if you would use it always when you mean it.
Consider the following Class of a program:
public class NarcissisticClass{
public Boolean lookingGood = true;
public void stillLookingGood(Boolean lookingGood){
this.lookingGood = lookingGood;
}
public void invertLookingGood(){
this.lookingGood = !this.lookingGood;
}
}
The method stillLookingGood(Boolean lookingGood) actually requires you to use “this.”. invertLookingGood(), on the other hand, does not need it. You could also just reference to the variable lookingGood.
I thought: Ok, being consistent and making everywhere clear, what I am referencing to, must be a good idea. Damage done and I am lost in a jungle of looooong expressions when writing advanced mathematical calculations. There you might use a relevant amount of global variables of the surrounding object and other objects as well. So, could it be that less is more in these situations? Should I just neglect writing this. if the compiler already knows what you mean? What is more important for other programmers or for yourself after not watching the code for maybe years: The consistancy of always knowing, that you mean this.variable or the general readability of code blocks?