Style question: Writing "this." before instance variable and methods: good or bad idea?
- by Uri
One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a this. For example: this.process(this.event).
A few of my students commented on this, and I'm wondering if I am teaching bad habits.
My rationale is:
1) Makes code more readable — Easier to distinguish fields from local variables.
2) Makes it easier to distinguish standard calls from static calls (especially in Java)
3) Makes me remember that this call (unless the target is final) could end up on a different target, for example in an overriding version in a subclass.
Obviously, this has zero impact on the compiled program, it's just readability. So am I making it more or less readable?
Related Question
Note: I turned it into a CW since there really isn't a correct answer.