471,579 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

Hungarian notation and variable names

For most of my variable names, I use Hungarian notation to determine between
one and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded really
strange. I've seen variable names that begin with _varName. Is that another
possibility?

Den
Nov 16 '05 #1
14 2038
I've been using _VarName for my private vars that my public VarName property
point to, and _varName for those variables that don't have public accessors.
All this at the class level, anything in the methods use varName.

--
Floyd Burger

"Denny" <de***@crane.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
For most of my variable names, I use Hungarian notation to determine between one and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded really
strange. I've seen variable names that begin with _varName. Is that another possibility?

Den

Nov 16 '05 #2
this is a topic of some debate in the .net community. Many companies
require hungarian for local and member variables but don't use them
for properties.

Some people take whether to use hungarian notation or not as an
article of religous faith and may become abusive if you don't do
exactly what they recommend. Ignore them and use whatever your
particular company has standardized on. Remember however, MS
recommends against using HN for .net.

On Mon, 24 May 2004 10:51:58 -0400, "Denny" <de***@crane.com> wrote:
For most of my variable names, I use Hungarian notation to determine between
one and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded really
strange. I've seen variable names that begin with _varName. Is that another
possibility?

Den


Nov 16 '05 #3
Where I work, the standard is that we use hungarian notation for
member "m_", function variables, and local variables. We don't use it
for properties. If I had my say on the member variables I'd probably
just use _.

On Mon, 24 May 2004 12:06:18 -0400, "Denny" <de***@crane.com> wrote:
There's no real standard at my company. Since this application is being
written from scratch, I can use any type of notation. I usually use HN for
variables but I want to be able to distinguish between a local variable and
a public property.
"Allen Anderson" <al***@sparkysystems.com> wrote in message
news:fk********************************@4ax.com.. .
this is a topic of some debate in the .net community. Many companies
require hungarian for local and member variables but don't use them
for properties.

Some people take whether to use hungarian notation or not as an
article of religous faith and may become abusive if you don't do
exactly what they recommend. Ignore them and use whatever your
particular company has standardized on. Remember however, MS
recommends against using HN for .net.

On Mon, 24 May 2004 10:51:58 -0400, "Denny" <de***@crane.com> wrote:
>For most of my variable names, I use Hungarian notation to determinebetween >one and the other. But what names can I use for public and private
>variables? I was using prv_varName and pub_varName but that soundedreally >strange. I've seen variable names that begin with _varName. Is thatanother >possibility?
>
>Den
>


Nov 16 '05 #4
Denny wrote:
There's no real standard at my company. Since this application is being
written from scratch, I can use any type of notation. I usually use HN for
variables but I want to be able to distinguish between a local variable and
a public property.


The standard .NET naming conventions enable you to distinguish between a
local variable and a property:

void Foo()
{
int bar = 5; // local variable
Bar = 5; // property
}
Nov 16 '05 #5
Denny wrote:
For most of my variable names, I use Hungarian notation to determine between
one and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded really
strange. I've seen variable names that begin with _varName. Is that another
possibility?


Hmm... isn't it bad form that you're using public member variables anyway?
Nov 16 '05 #6
Another popular way is to prefix the variable with m_

--
Jared Parson [MSFT]
ja******@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Floyd Burger" <fl***@adelphia.not> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
I've been using _VarName for my private vars that my public VarName property point to, and _varName for those variables that don't have public accessors. All this at the class level, anything in the methods use varName.

--
Floyd Burger

"Denny" <de***@crane.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
For most of my variable names, I use Hungarian notation to determine

between
one and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded really strange. I've seen variable names that begin with _varName. Is that

another
possibility?

Den


Nov 16 '05 #7
> The standard .NET naming conventions enable you to distinguish between a
local variable and a property:

void Foo()
{
int bar = 5; // local variable
Bar = 5; // property
}


Although this leads to poor readable code. Another thing which is more
important is the casing. I favour Pascal casing for public members, but like
camel casing for private members.

If I recall correctly, this is also what Microsoft recommends.

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #8
Anders Borum wrote:
The standard .NET naming conventions enable you to distinguish between a
local variable and a property:

void Foo()
{
int bar = 5; // local variable
Bar = 5; // property
}


Although this leads to poor readable code. [...]


How do you mean?
Nov 16 '05 #9
Anders Borum <a@b.dk> wrote:
The standard .NET naming conventions enable you to distinguish between a
local variable and a property:

void Foo()
{
int bar = 5; // local variable
Bar = 5; // property
}
Although this leads to poor readable code.


I think that's debatable. I certainly find it easier to read that than
_bar or m_bar - I can notice the case easily enough to distinguish
between the bar and Bar, but _bar and m_bar give me a mental hiccough
when reading.
Another thing which is more
important is the casing. I favour Pascal casing for public members, but like
camel casing for private members.

If I recall correctly, this is also what Microsoft recommends.


Indeed.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #10
if your saying the bar vs Bar is easier to read then Bar vs _Bar.
heh, thats pretty out there.

On Mon, 24 May 2004 20:48:23 +0100, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Anders Borum <a@b.dk> wrote:
> The standard .NET naming conventions enable you to distinguish between a
> local variable and a property:
>
> void Foo()
> {
> int bar = 5; // local variable
> Bar = 5; // property
> }


Although this leads to poor readable code.


I think that's debatable. I certainly find it easier to read that than
_bar or m_bar - I can notice the case easily enough to distinguish
between the bar and Bar, but _bar and m_bar give me a mental hiccough
when reading.
Another thing which is more
important is the casing. I favour Pascal casing for public members, but like
camel casing for private members.

If I recall correctly, this is also what Microsoft recommends.


Indeed.


Nov 16 '05 #11
Allen Anderson <al***@sparkysystems.com> wrote:
if your saying the bar vs Bar is easier to read then Bar vs _Bar.
heh, thats pretty out there.


Not really - there are plenty of people who use each of the
conventions. We just have different opinions, that's all.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #12
Allen Anderson wrote:
if your saying the bar vs Bar is easier to read then Bar vs _Bar.
heh, thats pretty out there.


I don't agree -- the former is easier on my eye.
Nov 16 '05 #13
fair enough

On Mon, 24 May 2004 21:39:52 +0100, Jon Skeet [C# MVP]
<sk***@pobox.com> wrote:
Allen Anderson <al***@sparkysystems.com> wrote:
if your saying the bar vs Bar is easier to read then Bar vs _Bar.
heh, thats pretty out there.


Not really - there are plenty of people who use each of the
conventions. We just have different opinions, that's all.


Nov 16 '05 #14
There's no real standard at my company. Since this application is being
written from scratch, I can use any type of notation. I usually use HN for
variables but I want to be able to distinguish between a local variable and
a public property.
"Allen Anderson" <al***@sparkysystems.com> wrote in message
news:fk********************************@4ax.com...
this is a topic of some debate in the .net community. Many companies
require hungarian for local and member variables but don't use them
for properties.

Some people take whether to use hungarian notation or not as an
article of religous faith and may become abusive if you don't do
exactly what they recommend. Ignore them and use whatever your
particular company has standardized on. Remember however, MS
recommends against using HN for .net.

On Mon, 24 May 2004 10:51:58 -0400, "Denny" <de***@crane.com> wrote:
For most of my variable names, I use Hungarian notation to determine betweenone and the other. But what names can I use for public and private
variables? I was using prv_varName and pub_varName but that sounded reallystrange. I've seen variable names that begin with _varName. Is that anotherpossibility?

Den

Nov 16 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Ronald S. Cook | last post: by
6 posts views Thread by Grey Squirrel | last post: by
3 posts views Thread by Grey Squirrel | last post: by
18 posts views Thread by dom.k.black | last post: by
12 posts views Thread by inhahe | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.