P
P.Hill
This is a syntax style question, but hopefully not the usually silly
personal choice issues. I find myself use lots of explicit "this."
while most Java code has few to none explicit "this." uses.
Over the last couple of years I have spent some time programming in
languages other than Java. Some other languages do not have implicit
this, they always require explicit this.somevirtualMethod( ... )
Another influence upon my style is the commonality of code completion in modern
IDEs, so I find myself typing this. then looking for the needed completion.
Between these two influences I find myself writing "this." more if not
very often in my Java classes. I learned long ago that it is just simplier
to stick with the defacto standard, so everyones code reads the same.
Years ago in C I was a fan of aligned braces, these days I have no
problem running with the K&R brace style that came into Java, because
that is the Java-style.
I realize lots of "this." is not the typical Java style, but didn't think
anything of it until a co-worker said that when he sees an explicit "this."
it is stylistically saying to him that the writer wants to bring attention
to which method or member the code is using, otherwise
if it just another call, he doesn't expect to see "this.". I didn't get
into any great discussion with him about it, so I'm not sure even where
he might expect to use explicit "this.".
I checked into various style guides, but could find none that mention
stylistic use of explicit "this." for certain cases.
Does anyone have any comments on such a stylistic usage of explicit
"this.", such that you tend to insert it under certain conditions to help
to make the code clearer, or expect that a certain pattern is being used
when you see "this." or find it actually be confusing to see an explicit
"this."
I'd be interested in your comments.
-Paul
personal choice issues. I find myself use lots of explicit "this."
while most Java code has few to none explicit "this." uses.
Over the last couple of years I have spent some time programming in
languages other than Java. Some other languages do not have implicit
this, they always require explicit this.somevirtualMethod( ... )
Another influence upon my style is the commonality of code completion in modern
IDEs, so I find myself typing this. then looking for the needed completion.
Between these two influences I find myself writing "this." more if not
very often in my Java classes. I learned long ago that it is just simplier
to stick with the defacto standard, so everyones code reads the same.
Years ago in C I was a fan of aligned braces, these days I have no
problem running with the K&R brace style that came into Java, because
that is the Java-style.
I realize lots of "this." is not the typical Java style, but didn't think
anything of it until a co-worker said that when he sees an explicit "this."
it is stylistically saying to him that the writer wants to bring attention
to which method or member the code is using, otherwise
if it just another call, he doesn't expect to see "this.". I didn't get
into any great discussion with him about it, so I'm not sure even where
he might expect to use explicit "this.".
I checked into various style guides, but could find none that mention
stylistic use of explicit "this." for certain cases.
Does anyone have any comments on such a stylistic usage of explicit
"this.", such that you tend to insert it under certain conditions to help
to make the code clearer, or expect that a certain pattern is being used
when you see "this." or find it actually be confusing to see an explicit
"this."
I'd be interested in your comments.
-Paul