Why does C# programmers use
-
m_Hmm ;)
m_cHammer :) I actually used m_cHandle the other day and it reminded me of him - Jason (SonorkID 100.611) Veni, vidi, VC - I came, I saw, Visual C
-
m_Hmm ;)
lol. Good one. cheers, Chris Maunder
-
m_cHammer :) I actually used m_cHandle the other day and it reminded me of him - Jason (SonorkID 100.611) Veni, vidi, VC - I came, I saw, Visual C
:laugh: m_cHammer.cantTouch(this); Regards, Alvaro A priest, a minister and a rabbi walk into a bar. The bartender says, "What is this, a joke?"
-
I'm with you, Konstantin. Superflous
this
's make me shudder. I will probably be scorned by the masses, but I'm going to continue using 'm_' prefixes for my member variables. cheers, Chris MaunderDamn you VS.NET owners. Don't you realise that VS6 users are superior? Simon If I type UpdataData(FALSE) instead of UpdateData(FALSE) once more... Sonork ID 100.10024
-
Is that more because of the force of habit, or does a need remain for the use of the m_ prefix to clarify things or help you write better code? I'm 50/50 on the matter; I've never collaborated on a project with others or worked as part of a team, so I tend to just do whatever I feel like doing at the time. - Jason (SonorkID 100.611) Veni, vidi, VC - I came, I saw, Visual C
In situations like
class Foo
{
protected int Field;
void SetField(int Field)
{
this.Field = Field;
}
}Gives me the heeby jeebies. I prefer
class Foo
{
protected int m_iField;
void SetField(int Field)
{
m_iField = Field;
}
}By using Hungarian in your member variables you are also never tempted to have:
class Foo
{
public int Field;
...
}(ie publicly accessible member variables). Sometimes public access to fields is fine (eg simple structures like points) but C# provides for properties which adds a level of future-proofing (and encapsulation) that I've found invaluable cheers, Chris Maunder
-
It sounds to me a bit like putting 'Earth' at the end of your own address. :| "I've read the Bible through a couple of times and it is a nice collection of morality stories and adventure fiction. Sort of like Huck Finn and Tom Sawyer except without the laughs." -- Michael P Butler 14 Mar '02
-
It sounds to me a bit like putting 'Earth' at the end of your own address. :| "I've read the Bible through a couple of times and it is a nice collection of morality stories and adventure fiction. Sort of like Huck Finn and Tom Sawyer except without the laughs." -- Michael P Butler 14 Mar '02
Daniel Ferguson wrote: It sounds to me a bit like putting 'Earth' at the end of your own address. That's what I do on things like CV's, quotes, etc. It may sound stupid (and childish), but I don't want to work with anyone who does not have enough of a sense of humour to appreciate that. So far it has worked to my advantage too.
David Wulff http://www.davidwulff.co.uk (updated) I could have created a cool signature brought to life with complex interactive DHTML, but I don't like to show off.
-
It is rather nice to use 'this' if you are not using the Hungarian notation. You can readily distinguish members. Another reason is that you get Intellisense support for members of the current class. Regards, Suresh
Exactly. That's why I often use it, even with C++. We don't use Hungarian notation where I work, and this is a little "workaround". I vote pro drink :beer:
-
Its a standard notation in oop languages a specially in Java and C# you are using namespacing in c# and in your namespace you might have some int or.. that have the same name but don't belong to the class?? The other thing is when you using this. you get intelihelp from Visual Studio :-) /Jarek "Imagination is more important than knowledge, for knowledge is limited while imagination embraces the entire world." -Albert Einstein
-
Damn you VS.NET owners. Don't you realise that VS6 users are superior? Simon If I type UpdataData(FALSE) instead of UpdateData(FALSE) once more... Sonork ID 100.10024
Simon Walton wrote: If I type UpdataData(FALSE) instead of UpdateData(FALSE) once more... ROTFL!! How many times have I done that...:rolleyes: cheers, Chris Maunder
-
:laugh: m_cHammer.cantTouch(this); Regards, Alvaro A priest, a minister and a rabbi walk into a bar. The bartender says, "What is this, a joke?"
LOL. :laugh:
-
I'm with you, Konstantin. Superflous
this
's make me shudder. I will probably be scorned by the masses, but I'm going to continue using 'm_' prefixes for my member variables. cheers, Chris Maunder -
It is rather nice to use 'this' if you are not using the Hungarian notation. You can readily distinguish members. Another reason is that you get Intellisense support for members of the current class. Regards, Suresh
G. Suresh wrote: Another reason is that you get Intellisense support for members of the current class. True, but I've found that you can get the same thing by always prefixing your member variables with the 'm_' wart. Then, when you want to reference one, type 'm_' and then hit Ctrl+Spacebar, and IntelliSense will pop up. These days I can hit Ctrl+Space almost as fast as Alt+F+S :) -- Russell Morris "WOW! Chocolate - half price!" - Homer Simpson, while in the land of chocolate.
-
It is rather nice to use 'this' if you are not using the Hungarian notation. You can readily distinguish members. Another reason is that you get Intellisense support for members of the current class. Regards, Suresh
The only names that can clash in C# are function arguments and member variables... right? Then it's very easy to spot which names are local to the member and which are local to the object/class. And "this" could very well be replaced with "m_", then there is no ambiguity (and less to type as well!) just m_ away :) Sonorked as well: 100.13197 jorgen FreeBSD is sexy.
-
I'm with you, Konstantin. Superflous
this
's make me shudder. I will probably be scorned by the masses, but I'm going to continue using 'm_' prefixes for my member variables. cheers, Chris Maunder -
Its a standard notation in oop languages a specially in Java and C# you are using namespacing in c# and in your namespace you might have some int or.. that have the same name but don't belong to the class?? The other thing is when you using this. you get intelihelp from Visual Studio :-) /Jarek "Imagination is more important than knowledge, for knowledge is limited while imagination embraces the entire world." -Albert Einstein
Jarek Gibek wrote: Its a standard notation in oop languages a specially in Java and C# I don't buy that. OOP is a methodology, and syntax is just a way to express it. This excessive use of "this" is just too much noice. Jarek Gibek wrote: you are using namespacing in c# and in your namespace you might have some int or.. that have the same name but don't belong to the class?? IIRC the only instance names that can clash in C# are member variables and function arguments. So I don't see how you can mistake a variable name for another (except for the member/function argument case). Jarek Gibek wrote: The other thing is when you using this. you get intelihelp from Visual Studio Ok, I'll buy that. But I'll bet you a million that "m_" is faster to type than "this." :) Sonorked as well: 100.13197 jorgen FreeBSD is sexy.