473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2114
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Phill | last post by:
Does anyone know the reasoning for Microsoft abandoning Hungarina Notation in C#? I have found it very usefull in C++. I like this style: constant: MY_CONSTANT methos: myMethod() class: ...
66
by: CMM | last post by:
So after three years of working in .NET and stubbornly holding on to my old hungarian notation practices--- I resolved to try to rid myself of the habit. Man, I gotta say that it is liberating!!! I...
24
by: Ronald S. Cook | last post by:
An ongoing philosophical argument, I would like your opinions. With the release of .NET, Microsoft spoke of moving away from the notation as a best practice. I'm a believer for a few reasons: ...
6
by: Grey Squirrel | last post by:
On wednesday my company will have an open ended discussion whether to standardize hungarian notation or pascal/cammel case notation. We'd love to recieve some feedback on what other people are...
3
by: Grey Squirrel | last post by:
On wednesday my company will have an open ended discussion whether to standardize hungarian notation or pascal/cammel case notation. We'd love to recieve some feedback on what other people are...
14
by: Ronald S. Cook | last post by:
I've been weaning myself off of Hungarian notation because that's what Microsoft is telling me to do, and I want to be a good little MS developer. But things keep coming up that make me miss my...
18
by: dom.k.black | last post by:
I am looking at starting a new piece of work for a company who are heavily into hungarian notation for C coding. Any killer arguments for NOT carrying this terrible practice forward into new C++...
12
by: inhahe | last post by:
Does anybody know of a list for canonical prefixes to use for hungarian notation in Python? Not that I plan to name all my variables with hungarian notation, but just for when it's appropriate.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.