Wasim Ayoubi<br />SCJA1.0(BETA), SCJP1.4, SCWCD1.4<br />Next ???
Wasim Ayoubi<br />SCJA1.0(BETA), SCJP1.4, SCWCD1.4<br />Next ???
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:
I agree with Charles.
Also note that making a difference in how you invoke a static or an instance method makes the code less flexible: changing a method from static to non-static (or the other way around) becomes more work.
Originally posted by Henry Wong:
Don't think the code is more readable -- just longer.
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 ak pillai:
Beginners can easiliy fall into the following pitfall:
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
In practise, the purpose of 'this' is to reduce confusion over instance/method-local variable names and between inner/outer classes; as I said earlier:Originally posted by ak pillai:
If you are a beginner it makes sense to use this. But once you are used to it, then it is more of a clutter. Beginners can easiliy fall into the following pitfall
So whether you're an expert or a beginner, you would always use:Originally posted by Charles Lyons:
I only ever use 'this' when there is the possibility for confusion over variable names
Originally posted by Wasim Ayoubi:
I am doing some code refactoring and wondering if using "this" operator is an addon to readability or not.
Reid - SCJP2 (April 2002)
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Tony Morris:
Redundant redundancy has never helped anybody
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
Tony Morris
Java Q&A (FAQ, Trivia)
"I'm not back." - Bill Harding, Twister
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
Tony Morris
Java Q&A (FAQ, Trivia)
Reid - SCJP2 (April 2002)
Originally posted by Paul Clapham:
Tony, I believe a thorough understanding of reductio ad absurdum would include a study of intuitionism, which rejects the law of the excluded middle, upon which reductio critically depends. And it rejects the concept of infinity, so naturally infinite descent is out as well. It only permits the discussion of objects that can be constructively described by human beings; and since all computer programs are such objects, I think it is completely relevant to your post.
Tony Morris
Java Q&A (FAQ, Trivia)
Tony Morris
Java Q&A (FAQ, Trivia)
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
"I'm not back." - Bill Harding, Twister
There is no emoticon for what I am feeling!
Originally posted by Wasim Ayoubi:
Hi All,
I am doing some code refactoring and wondering if using "this" operator is an addon to readability or not.
public class XX{
String foo;
public String getFoo(){
return foo;
}
public void doX(){
......
......
this.getFoo();
//or
getFoo();
}
}
I believe using the this.getFoo() is better, at least you can figure it is not a static method on the class and you are getting a state of an object.
Some people will obsessively put this in front of every ... field reference, arguing that it makes it "clearer and more explicit." Don't do it. There's a reason that we use high-level languages: They do things for us. If you put this in when it's not necessary, you will confuse and annoy everyone who reads your code...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Originally posted by Ken Blair:
I agree with Bruce.
I have no idea what Tony and Jim are rambling about.
I like toast.
Tony Morris
Java Q&A (FAQ, Trivia)
"I'm not back." - Bill Harding, Twister
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|