473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2138
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.co m> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.co m> 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.co m> 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***@sparkysy stems.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.co m> 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******** ******@TK2MSFTN GP12.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.co m> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
10430
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: MyClass variable: iMyInteger
66
3711
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 love it. At first I struggled with how to name controls. I tried to keep some sort of notation with them... but I threw that away too!!! I now name them as if they were simply properties of the form (FirstNameLabel, etc.)... which they ARE!......
24
3838
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: 1) Consistency throughout and knowing which objects are yours (clsEmployee, tblEmployee, frmEmployee, etc). 2) Not having to name an employee form EmployeeForm.aspx because the mane is already taken by your class named Employee.cs
6
4070
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 using out there and why. Thanks!
3
10562
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 using out there and why. Thanks!
14
1552
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 little 3-character prefixes. I'm fine with EmployeeFirstNameLabel instead of lblEmployeeFirstName, but at the table and class level, I get frustrated because terms I want to use reserved keywords. I wanted "Event" and "User" as classes and table...
18
4251
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++ code?
12
3598
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.