Style question: Writing "this." before instance variable and methods: good or bad idea?

Posted by Uri on Stack Overflow See other posts from Stack Overflow or by Uri
Published on 2008-09-28T23:27:17Z Indexed on 2010/05/21 1:40 UTC
Read the original article Hit count: 252

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about c++