this (another C# programmer rant)
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
-
Agreed.
this
,Self
andMe
are keywords that serve no purpose.To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.
They serve limited purpose, but rarely do any harm.
-
Agreed.
this
,Self
andMe
are keywords that serve no purpose.To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.
leonej_dt wrote:
Agreed. this, Self and Me are keywords that serve no purpose.
I wouldn't go that far. I avoid 'this' like the plague as a general rule, but I'll still use it as a parameter to a function, for example. What's your alternative in that case?
-
leonej_dt wrote:
Agreed. this, Self and Me are keywords that serve no purpose.
I wouldn't go that far. I avoid 'this' like the plague as a general rule, but I'll still use it as a parameter to a function, for example. What's your alternative in that case?
-
I do it just to piss people off. :-D
PIEBALDconsult wrote:
I do it just to piss people off.
You're one step closer to "Outlaw" status.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
I would be more concern of naming a member variable "k". Why do you hate "this" so much?
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
Almost certainly it's to kick in intellisense. I do it all the time; it's a form of insurance to gurantee you are typing the correct variable name. At worst it's a difference of esthetics, it makes no other difference.
"It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson
-
I think his complaint is that
this.k
could be easily written simply ask
. Although yes, k is a terrible name for a class member.----
You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.
Shog9 wrote:
Although yes, k is a terrible name for a class member.
In the context of the class, it makes sense. Combinations(n, k), where "n" and "k" are the common math terms for these concepts. Marc
-
i use letters all the time for couters in a for loop, do you hate that?
for(int i = 0; i < this.k; i++){
MarcClifton.Anger++;
}Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. -Fred Brooks
StevenWalsh wrote:
i use letters all the time for couters in a for loop, do you hate that?
I do that all the time. And I start with "i", harking back to the days of Fortran, where "i" was the first of several letters that defaulted to integer type. Pretty crazy. Marc
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
No C++ programmers in that thread. This.IsGreat(true); Personally, I really hate to see “::someMetod() “ in the code. Why it is so difficult for someone to type the base class name?!? - especially if you have a multiple inheritance.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
modified on Thursday, September 18, 2008 2:19 PM
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
Uh... those of you that are playing the IntelliSense card... Alt+Right Arrow is your friend ;)
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
I am not a fan of "this." as a prefix (coming from a C++ background). The place that I work at does new development in C# and has decided to use the Microsoft StyleCop to check the code style. One of the rules of the StyleCop is that member access must be prefixed by "this.". Apparently this is the Microsoft recommended way of indicating member variable access. John
-
I've seen comments... probably here... from folk who use it to make it obvious they're using member variables (replacing the old
m_
prefix, essentially). I don't care for it either.----
You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.
Shog9 wrote:
I don't care for it either.
Microsoft StyleCop enforces use of this on private members. StyleCop is being adopted more and more within Microsoft so expect more of it going forward. To be honest I don't care much either way - though to date I've used the _ for private fields.
Kevin
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
Visual Studio generated code uses it everywhere. Drives me nuts coming from a C++ background.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I am not a fan of "this." as a prefix (coming from a C++ background). The place that I work at does new development in C# and has decided to use the Microsoft StyleCop to check the code style. One of the rules of the StyleCop is that member access must be prefixed by "this.". Apparently this is the Microsoft recommended way of indicating member variable access. John
jbarton wrote:
Apparently this is the Microsoft recommended way of indicating member variable access.
Basically, StyleCop is being used more and more across Microsoft teams so expect more of it going forward. It's the Java house style btw. Note that StyleCop is customisable though. You can disable that rule for your team.
Kevin
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
I simply use it because it helps me figure out what's a class member or not, although laziness is also a good justification. :)
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
-
jbarton wrote:
Apparently this is the Microsoft recommended way of indicating member variable access.
Basically, StyleCop is being used more and more across Microsoft teams so expect more of it going forward. It's the Java house style btw. Note that StyleCop is customisable though. You can disable that rule for your team.
Kevin
I wish I could disable this warning. It was a decision from higher up that StyleCop would be used pretty much as is (a few warnings have been turned off, but for the most part they are all on). There is a check-in policy that says that there can't be any StyleCop warnings based on the global team settings. I can't turn it off just for my machine or I would get warnings and the check-in would fail.
-
I wish I could disable this warning. It was a decision from higher up that StyleCop would be used pretty much as is (a few warnings have been turned off, but for the most part they are all on). There is a check-in policy that says that there can't be any StyleCop warnings based on the global team settings. I can't turn it off just for my machine or I would get warnings and the check-in would fail.
Too bad for you. Personally I'm not much fussed by this rule. There are many things that irritate me more. :)
Kevin
-
In vs2k3, intilisense didn't start as soon as you began typing. IF you weren't sure what the variable was called you had to type
this.
to make it come up. Not needed int 2k8, I never used 2k5; could just be an old bad habit.Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc