|
-
Apr 24th, 2006, 07:50 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Class Member Variables Naming Convention
Microsoft recommends using something like below for your class naming conventions.
VB Code:
public class Customer
{
string name;
public string Name
{
set
{
name = value;
}
get
{
return name;
}
}
}
Does anyone know why Microsoft wanted to get away from using the m_? It makes it a bit easier to read and know if you see that m_ it is a class variable.
VB Code:
public class Customer
{
string m_name;
public string Name
{
set
{
m_name = value;
}
get
{
return m_name;
}
}
}
Your thoughts please?
-
Apr 24th, 2006, 09:30 AM
#2
Re: Class Member Variables Naming Convention
The idea is to use names that describe the data, not the variable. The IDE can tell you what you need to know about the variable by mousing over it. Personally, I always qualify my member variables with 'Me' (VB) or 'this' (C#) when I use them anyway. Most of what I've read on MSDN suggests that what convention you use for private variables is of little consequence anyway. They are more concerned with the public interface and that it conforms to what's used in the rest of the Framework.
-
Apr 24th, 2006, 10:12 AM
#3
Fanatic Member
Re: Class Member Variables Naming Convention
comming from VB6 and using hungairan notation I found it hard to move way from at first, but now making sure i use more discriptive names for the object(varibale) makes more sence. the following document gives a good account of coding style in .Net focusng on C#
Conding style
Hope this helps!!!
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
-
Apr 24th, 2006, 11:50 AM
#4
Thread Starter
Fanatic Member
Re: Class Member Variables Naming Convention
Thanks for the replies. For right now I'll stick with the using the first example.
-
Apr 24th, 2006, 12:53 PM
#5
Fanatic Member
Re: Class Member Variables Naming Convention
I find it's nice to have private class variables prefixed w/ an underscore - it's a nice heads up re: what you're using.
-
Apr 24th, 2006, 12:58 PM
#6
Re: Class Member Variables Naming Convention
I use the _ method too for private variables. That way I know for sure if I'm accessing the variable directly or through the property.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|