473,396 Members | 1,916 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

Ant
Good or bad? I've always used HG in VB6, but the .NET guidelines say no.
I think it's useful as you can have similar named variables differentiated
only by identifier type, hence more variable options. What's the standard? Is
it still considered choice of team?

Many thanks for your thoughts on this

Ant
Nov 17 '05 #1
14 3650
Is it still considered choice of team?


For private variables, yes. The .NET naming guidelines only cover
publicly exposed members.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
Personally, I think that HG is grossly overused. I thought that using
it even in C was a bad idea.

HG was originally created for programming in assembly language, where
it makes tremendous sense: you cannot tell just from a declaration what
type a variable is meant to be; you have to encode it in a name.

In C, HG was problematic: yes, you could tell at a glance what type
your variable was, but then if your variable declaration was so far
away that you couldn't easily find it and with it the type, then there
was something wrong with the way you were coding C, IMHO.

In C#, with Intellisense and the ability to declare variables as you
need them, it makes even less sense, and the arguments against HG
become even stronger. The best anti-HG argument is: what happens when
you change the type of a variable, property, etc? What happens when you
discover that you need that int property to be a decimal property?
Suddenly you have to re-engineer the property name everywhere it's
used, or live with a decimal property named iLinearFeet or something
like that. Yuck.

Intellisense will tell you what type a thing is just by mousing over
it. I see no reason for adding HG to that, especially given the
problems it brings with it.

Nov 17 '05 #3
On 27 Aug 2005 12:22:23 -0700, "Bruce Wood" <br*******@canada.com>
wrote:
In C#, with Intellisense and the ability to declare variables as you
need them, it makes even less sense, and the arguments against HG
become even stronger. The best anti-HG argument is: what happens when
you change the type of a variable, property, etc? What happens when you
discover that you need that int property to be a decimal property?
Suddenly you have to re-engineer the property name everywhere it's
used, or live with a decimal property named iLinearFeet or something
like that. Yuck.


Well, it's maybe not so bad, because in VS.NET 2005 there is the
Refactor feature that allows you to change a field/property/method
name very easily.

Yet I agree with you - IntelliSense eliminates HG need.

Another point against HG not mentioned here: HG is useles because one
cannot make it useful. While adding "str" or "int" to variable names
might seem appropriate for string and int types, then what would you
do for objects like DataListItemEventHandler or TransformChain? I've
seen people blindly following their HG habit just to flood their .NET
code with idiotic prefixes like cnsc_ or dgcer_ which make no sense
to anyone, including themselves.
Nov 17 '05 #4
or taken to its limit everything is an object so put o_ in front of it
all

Nov 17 '05 #5
tal_mcmahon <ta*********@hotmail.com> wrote:
or taken to its limit everything is an object so put o_ in front of it
all


Unfortunately, I've seen that in plenty of code samples...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6
That's frightening.

Nov 17 '05 #7
Mattias Sjögren wrote:
Is it still considered choice of team?


For private variables, yes. The .NET naming guidelines only cover
publicly exposed members.


Which doesn't mean using HN for private members is recommended. It just
means that there's no recommendation for private members.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #8
Mattias Sjögren wrote:
Is it still considered choice of team?


For private variables, yes. The .NET naming guidelines only cover
publicly exposed members.


Which doesn't mean using HN for private members is recommended. It just
means that there's no recommendation for private members.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #9
On Wed, 31 Aug 2005 00:47:31 -0700, "Joerg Jooss"
<ne********@joergjooss.de> wrote:
Mattias Sjögren wrote:
> Is it still considered choice of team?


For private variables, yes. The .NET naming guidelines only cover
publicly exposed members.


Which doesn't mean using HN for private members is recommended. It just
means that there's no recommendation for private members.

Cheers,


Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)
Nov 17 '05 #10
On Wed, 31 Aug 2005 00:47:31 -0700, "Joerg Jooss"
<ne********@joergjooss.de> wrote:
Mattias Sjögren wrote:
> Is it still considered choice of team?


For private variables, yes. The .NET naming guidelines only cover
publicly exposed members.


Which doesn't mean using HN for private members is recommended. It just
means that there's no recommendation for private members.

Cheers,


Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)
Nov 17 '05 #11
Usenet*User wrote:
Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)


This is one naming convention many developers seem to use, but it is
not an official recommendation.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #12
Usenet*User wrote:
Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)


This is one naming convention many developers seem to use, but it is
not an official recommendation.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #13
Usenet*User <**@*.**> wrote:
Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)


There are lots of conventions - naming them with no prefix, naming them
with m_ (and g_ for statics) etc. None of these are specified in the MS
conventions, however.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #14
Usenet*User <**@*.**> wrote:
Actually, there is one naming convention for private fields: use camel
notation and prefix with underscore. This way they are conveniently
grouped together at the top of IntelliSense list (in C#) or in the
bottom (VB.NET)


There are lots of conventions - naming them with no prefix, naming them
with m_ (and g_ for statics) etc. None of these are specified in the MS
conventions, however.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #15

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

Similar topics

14
by: Denny | last post by:
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...
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: ...
24
by: darrel | last post by:
I just discovered that MS recommends that we NOT use hungarian notation with the .net framework: http://msdn2.microsoft.com/en-us/library/ms229045.aspx What are the real cons for using it? ...
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...
3
by: Ronald S. Cook | last post by:
For all those anti-Hungarian notation people out there, how would you name an employee first name label and textbox on an create/modify employee form, respectively (please)? Thanks, Ron
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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.