SCJP 1.4
Originally posted by Rajasekar Elango:
Hi rathi,
this is used to diffenciate between local variable and instance variable
For eg if you want to initialize i and j in constructor
this is not required in your example.
Regards,
Raja
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
Some people prefer to always use the this prefix because they find it be more readable. Often those are people coming from other languages like Smalltalk, which unlike Java always require such a prefix.
=======================<br />SUN: SCJP, SCWCD, SCBCD, SCEA, SCDJWS<br />BEA: Certified Architect<br />M$: MCP, MCSA
Originally posted by Hank GU:
I am one of the "some people". in industry, readibility is really important when the code can be maintained by many people.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Hank GU:
I also feel that it looks more OO when "this" got prefixed for class level variables and methods.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Originally posted by Roger Chung-Wee:
I never use this because - as Ilja says - it adds to code clutter.
I also never do this sort of thing.
Hiding of class or instance variables is prone to error or confusion and is best avoided, in my opinion.
There is no emoticon for what I am feeling!
Originally posted by Don Kiddick:
IMHO this is misleading when it comes to instance methods as it indicates that the method that gets executed is in the class that you are currently editing but this is not the case - the method may be overriden.
There is no emoticon for what I am feeling!
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Originally posted by Roger Chung-Wee:
A problem with variable hiding is that one day someone will write this.
I'd rather avoid the potential problem by not hiding variables. Some people have standards for naming which involves prefixes or suffixes to distinguish their instance variables from their local variables.
There is no emoticon for what I am feeling!
Originally posted by Roger Chung-Wee:
A problem with variable hiding is that one day someone will write this.
I'd rather avoid the potential problem by not hiding variables.
Some people have standards for naming which involves prefixes or suffixes to distinguish their instance variables from their local variables.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Roger Chung-Wee:
Even better: Naming :roll:
There is no emoticon for what I am feeling!
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ernest Friedman-Hill:
I still like to use scope warts. Laugh if you must, but they work for me and I mandate them on the projects I run.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
And did you know that Eclipse can syntax highlight fields differently from local variables?
Originally posted by Jeff Albrechtsen:
Honestly, I've never read anyone else with this concern... In Java,
polymorphism is part of the furniture, as they say in Jamaica.
Originally posted by Ernest Friedman-Hill:
Yes, I do -- there's a discussion about that in the blog entry I linked to.
If I can't write good code unless I'm using a particular tool, well, than what does that say about me?
As has been pointed out many times, tests can never prove the absence of bugs, and practices that prevent them from happening are a good thing.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |