473,396 Members | 2,039 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.

Why NOT hungarian notation?

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?

I tend to use it a lot, especially when IDing my controls. For instance the
controls in a contact form I create could be IDed as such:

tbx_firstName
tbx_emailAddress
ddl_state

I find this really helpful when in codebehind.

is the 'no hungarian' merely a preference MS has, or are there specific cons
to me being stubborn and sticking with it?

-Darrel

--
================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Dec 8 '06 #1
24 2333
"darrel" <no*****@nowhere.comwrote in message
news:eV**************@TK2MSFTNGP06.phx.gbl...
>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
Weird, isn't it! It was all the rage for years, then suddenly they don't
like it any more...
What are the real cons for using it?
None whatever.
I tend to use it a lot, especially when IDing my controls.
Me too - all the time.
I find this really helpful when in codebehind.
Likewise.
is the 'no hungarian' merely a preference MS has,
I have no idea...
or are there specific cons to me being stubborn and sticking with it?
None whatever.
Dec 8 '06 #2
>or are there specific cons to me being stubborn and sticking with it?
>
None whatever.
Ha! Thanks for the feedback, Mark. At least I can find peace with me knowing
that I'm not alone in wanting to stick with it. ;o)

-Darrel
Dec 8 '06 #3
The biggest argument against hungarian notation is that it makes it harder
to refactor code. People argue that it's violates the Don't Repeat Yourself
(DRY) principle. Personally, I think that's a little much, but the side
effect IS the same. If you change the type of your variable, you now need to
change all instances of that variable.

if you have rptBooks and want to change it to a datagrid, you now have to
refactor your name or risk having hard code to maintain.

With the advances in IDEs generally and intellisense specifically, the
question is what value does hungarian notation offer?

I'd be interested in taking a look at a codebehind page you feel it ads
value.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"darrel" <no*****@nowhere.comwrote in message
news:eV**************@TK2MSFTNGP06.phx.gbl...
>>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

Weird, isn't it! It was all the rage for years, then suddenly they don't
like it any more...
>What are the real cons for using it?

None whatever.
>I tend to use it a lot, especially when IDing my controls.

Me too - all the time.
>I find this really helpful when in codebehind.

Likewise.
>is the 'no hungarian' merely a preference MS has,

I have no idea...
>or are there specific cons to me being stubborn and sticking with it?

None whatever.
Dec 8 '06 #4
"darrel" <no*****@nowhere.comwrote in message
news:eC*************@TK2MSFTNGP06.phx.gbl...
>>or are there specific cons to me being stubborn and sticking with it?

None whatever.

Ha! Thanks for the feedback, Mark. At least I can find peace with me
knowing that I'm not alone in wanting to stick with it. ;o)
Without doubt the stupidest reason for not using it I've ever come across
was that you might change the underlying datatype (e.g. from byte to
integer) that a variable referred to, so you'd have to go through your
entire code and change it...

Well, my copy of VS.NET has got a find and replace utility...
Dec 8 '06 #5
"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:%2***************@TK2MSFTNGP06.phx.gbl...
If you change the type of your variable, you now need to change all
instances of that variable.
Personally, I would use Find / Replace for such a task - wouldn't you...?
Dec 8 '06 #6
On Fri, 8 Dec 2006 10:55:56 -0600, "darrel" <no*****@nowhere.com>
wrote:
>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?
Nothing although the various 'dialects' can be confusing and
internally inconsistent.
>I tend to use it a lot, especially when IDing my controls. For instance the
controls in a contact form I create could be IDed as such:

tbx_firstName
tbx_emailAddress
ddl_state

I find this really helpful when in codebehind.
My preference is to be verbose as needed to make the code easier to
read. A few extra key strokes for clarity can go a long a way i.e.
firstNameTextBox or firstNameEdit.
>is the 'no hungarian' merely a preference MS has, or are there specific cons
to me being stubborn and sticking with it?
You may run into situations where corporate/department/office policy
does not appreciate hungarian notation as much as you do. For all
practical purposes IntelliSense and similar tools make hungarian
notation obsolete.

regards
A.G.
Dec 8 '06 #7
Hi,

Registered User wrote:
You may run into situations where corporate/department/office policy
does not appreciate hungarian notation as much as you do. For all
practical purposes IntelliSense and similar tools make hungarian
notation obsolete.

regards
A.G.
Very much in the contrary IMHO. I tend to forget how my variables are
named, especially which letter they start with, but I do not forget
which type they have. If I want a string, I type "str" and all the
strings are nicely grouped in Intellisense. If anything, Intellisense
makes hungarian notation even more useful!!

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Dec 8 '06 #8
"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:u0**************@TK2MSFTNGP02.phx.gbl...
Registered User wrote:
>You may run into situations where corporate/department/office policy
does not appreciate hungarian notation as much as you do. For all
practical purposes IntelliSense and similar tools make hungarian
notation obsolete.

regards
A.G.

Very much in the contrary IMHO. I tend to forget how my variables are
named, especially which letter they start with, but I do not forget which
type they have. If I want a string, I type "str" and all the strings are
nicely grouped in Intellisense. If anything, Intellisense makes hungarian
notation even more useful!!
Tout à fait d'accord avec toi, mon pote!

Which is to say that I agree entirely with Laurent.

Hungarian notation makes it easier for me to write my applications - if I
didn't use it, it would make it more difficult for me to write my
applications.

I think the OP would also agree with the above...
Dec 8 '06 #9
If anything, Intellisense makes hungarian notation even more useful!!

Excellent point!

-Darrel
Dec 8 '06 #10
On Fri, 8 Dec 2006 12:51:39 -0500, Karl Seguin wrote:

With the advances in IDEs generally and intellisense specifically, the
question is what value does hungarian notation offer?
So true! Especially as VS 2005 has very good refactoring that kicks in when
you rename a variable!
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 8 '06 #11
Darrel,

for a very interesting article on the issues and history, read :

http://www.joelonsoftware.com/articles/Wrong.html


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"darrel" <no*****@nowhere.comwrote in message news:eV**************@TK2MSFTNGP06.phx.gbl...
>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?

I tend to use it a lot, especially when IDing my controls. For instance the controls in a contact
form I create could be IDed as such:

tbx_firstName
tbx_emailAddress
ddl_state

I find this really helpful when in codebehind.

is the 'no hungarian' merely a preference MS has, or are there specific cons to me being stubborn
and sticking with it?

-Darrel

--
================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA

Dec 8 '06 #12
no.

find/replacing is dangerous. What happens if you use that same name
somewhere else but don't change its type?

I use JetBrains Resharper which provides much better refactoring than VS.NET
2005. It would do it for me. So that's a case against my own argument :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:%2***************@TK2MSFTNGP06.phx.gbl...
>If you change the type of your variable, you now need to change all
instances of that variable.

Personally, I would use Find / Replace for such a task - wouldn't you...?
Dec 8 '06 #13
I hope you don't use "obj" or "o" ....
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"darrel" <no*****@nowhere.comwrote in message
news:eV**************@TK2MSFTNGP06.phx.gbl...
>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?

I tend to use it a lot, especially when IDing my controls. For instance
the controls in a contact form I create could be IDed as such:

tbx_firstName
tbx_emailAddress
ddl_state

I find this really helpful when in codebehind.

is the 'no hungarian' merely a preference MS has, or are there specific
cons to me being stubborn and sticking with it?

-Darrel

--
================================================== ===============
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Dec 8 '06 #14
On Fri, 08 Dec 2006 19:58:47 +0100, Laurent Bugnion
<ga*********@bluewin.chwrote:
>
Very much in the contrary IMHO. I tend to forget how my variables are
named,
I would suggest using a more meaningful naming convention but I just
can't fathom the situation you describe.

regards
A.G.
Dec 8 '06 #15
"Karl Seguin" <ka********@removeopenmymindremovemetoo.andmenetwr ote in
message news:up**************@TK2MSFTNGP03.phx.gbl...
find/replacing is dangerous. What happens if you use that same name
somewhere else but don't change its type?
Then I would correct it on the unlikely event that that would occur...

Also, I wouldn't just blithely hit "Replace all"...
I use JetBrains Resharper which provides much better refactoring than
VS.NET 2005. It would do it for me. So that's a case against my own
argument :)
LOL! Well there you go!
Dec 8 '06 #16
I do use o for local objects, mo for class or module level and go for global
objects. Hungarian Notation rocks and after using it for the last 15 years I've
yet to see a good reason not to.

On Fri, 8 Dec 2006 15:41:22 -0500, "Karl Seguin"
<ka********@removeopenmymindremovemetoo.andmenetwr ote:
>I hope you don't use "obj" or "o" ....
Dec 8 '06 #17
"Jay Pondy" <jp****@bellsouth.netwrote in message
news:va********************************@4ax.com...
Hungarian Notation rocks and after using it for the last 15 years I've
yet to see a good reason not to.
Likewise.
Dec 8 '06 #18
That is a very good article. I wish I had known about Apps Hungarian because
apparently I am an abuser of Apps System where the type is a small part of the
variable naming convention rather than the "kind" of thing it is.

When I see code that does not use Hungarian notation I feel like half my brain
is turned off and I then have to work twice as hard to stay in the same place.
Joel does an excellent job of explaining why and where that perception comes
from.

Thanks for a great perspective.

On Fri, 8 Dec 2006 15:30:13 -0400, "Juan T. Llibre" <no***********@nowhere.com>
wrote:
>Darrel,

for a very interesting article on the issues and history, read :

http://www.joelonsoftware.com/articles/Wrong.html


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"darrel" <no*****@nowhere.comwrote in message news:eV**************@TK2MSFTNGP06.phx.gbl...
>>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?

I tend to use it a lot, especially when IDing my controls. For instance the controls in a contact
form I create could be IDed as such:

tbx_firstName
tbx_emailAddress
ddl_state

I find this really helpful when in codebehind.

is the 'no hungarian' merely a preference MS has, or are there specific cons to me being stubborn
and sticking with it?

-Darrel

--
================================================= ================
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Dec 9 '06 #19
Thus wrote Mark,
"darrel" <no*****@nowhere.comwrote in message
news:eC*************@TK2MSFTNGP06.phx.gbl...
>>>or are there specific cons to me being stubborn and sticking with
it?

None whatever.
Ha! Thanks for the feedback, Mark. At least I can find peace with me
knowing that I'm not alone in wanting to stick with it. ;o)
Without doubt the stupidest reason for not using it I've ever come
across was that you might change the underlying datatype (e.g. from
byte to integer) that a variable referred to, so you'd have to go
through your entire code and change it...

Well, my copy of VS.NET has got a find and replace utility...
Unfortunately, changing source code all over the place usually means going
through the entire test cycle of that component *again*, even though semantically
there's no change. Accordingly, changing a variable name because of a type
change is not only stupid but also expensive, IMNSHO.

Cheers.
--
Joerg Jooss
ne********@joergjooss.de
Dec 9 '06 #20
Thus wrote Joerg,

Thus wrote Mark,
>"darrel" <no*****@nowhere.comwrote in message
news:eC*************@TK2MSFTNGP06.phx.gbl...
>>>>or are there specific cons to me being stubborn and sticking with
it?
>
None whatever.

Ha! Thanks for the feedback, Mark. At least I can find peace with me
knowing that I'm not alone in wanting to stick with it. ;o)
Without doubt the stupidest reason for not using it I've ever come
across was that you might change the underlying datatype (e.g. from
byte to integer) that a variable referred to, so you'd have to go
through your entire code and change it...

Well, my copy of VS.NET has got a find and replace utility...
Unfortunately, changing source code all over the place usually means
going through the entire test cycle of that component *again*, even
though semantically there's no change. Accordingly, changing a
variable name because of a type change is not only stupid but also
expensive, IMNSHO.
Of course this only applies if you miss renaming variables when implementing
the type change or decide to update your type prefixes throughout.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Dec 9 '06 #21
"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
Unfortunately, changing source code all over the place usually means going
through the entire test cycle of that component *again*, even though
semantically there's no change.
"All over the place..."??? With a properly designed system, this should
hardly ever happen anyway i.e. your database field types, class properties
etc should already be agreed upon before you start writing your first line
of code. If that isn't the case, then that *really* is stupid...
Accordingly, changing a variable name because of a type change is not only
stupid but also expensive, IMNSHO.
Not nearly so stupid and expensive as having to refer constantly to
IntelliSense, or the technical spec, every time you need to know what
datatype a variable or class property is...

Being a jobbing IT consultant, I'm quite often brought in to fix or update a
system where there is no documentation, and I always charge extra if the
code doesn't use Hungarian notation or, at least, *some* sort of notation
because, without it, it will take me proportionately longer to do my work.

E.g. imagine a Customer class with a CustomerID property - what datatype is
CustomerID?
Dec 9 '06 #22
On Sat, 9 Dec 2006 11:02:10 -0000, "Mark Rae" <ma**@markNOSPAMrae.com>
wrote:
>
E.g. imagine a Customer class with a CustomerID property - what datatype is
CustomerID?
I dunno it might be a value type instead. Once I find out I won't need
to be constantly reminded that CustomerID is a string or an int or
even an object of type CustomerID. I find this ability especially
helpful when working with generics.

The question itself reads as if you are suggesting being consistant
and using hungarian notation in every scope. I agree, if hungarian
notation is to be used at all, it should be used everywhere so all
consumers can receive all the supposed benefits.

public class Customer
{
// public int int_CustomerID {...}
// public string str_CustomerID {...}
public CustomerID custid_CustomerID {...}
public string str_CustomerName {...}
...
}

regards
A.G.

Dec 9 '06 #23
"Registered User" <n4***@ix.netcom.comwrote in message
news:o9********************************@4ax.com...
>>E.g. imagine a Customer class with a CustomerID property - what datatype
is
CustomerID?
I dunno
Of course you don't...How could you...?
it might be a value type instead.
Instead of what...?
Once I find out I won't need to be constantly reminded that CustomerID is
a
string or an int or even an object of type CustomerID.
LOL! Well, if you have a photographic memory, I certainly don't! Yes, once I
know it's an int or whatever, I'll retain that particular piece of
information for as long as I need to. But next week, next month, next year
when I come to revisit the code in response to a request for change or
whatever, I'll almost certainly have forgotten it again...
I find this ability especially helpful when working with generics.
Me too.
The question itself reads as if you are suggesting being consistant
and using hungarian notation in every scope.
I most certainly am.
I agree, if hungarian notation is to be used at all, it should be used
everywhere so all consumers can receive all the supposed benefits.
I couldn't agree more!
Dec 9 '06 #24
On Sat, 9 Dec 2006 13:28:07 -0000, "Mark Rae" <ma**@markNOSPAMrae.com>
wrote:
>"Registered User" <n4***@ix.netcom.comwrote in message
news:o9********************************@4ax.com.. .
>>>E.g. imagine a Customer class with a CustomerID property - what datatype
is
CustomerID?
I dunno

Of course you don't...How could you...?
>it might be a value type instead.

Instead of what...?
Instead of a nullable datatype.
>
>Once I find out I won't need to be constantly reminded that CustomerID is
a
string or an int or even an object of type CustomerID.

LOL! Well, if you have a photographic memory, I certainly don't! Yes, once I
know it's an int or whatever, I'll retain that particular piece of
information for as long as I need to. But next week, next month, next year
when I come to revisit the code in response to a request for change or
whatever, I'll almost certainly have forgotten it again...
Myself as well but the time frame can be shorter. It never hurts to
review the code your going to touch. Part of the review is to refresh
the understanding of the existing design and code. The balance is to
consider and understand what changes are required and how those should
be accomplished. If this isn't done the programmer is just hacking on
the code trying to make 'it' (the desired changes) work.
>I find this ability especially helpful when working with generics.

Me too.
It doesn't take much to make CustomerID a generic.
public Customer<CustomerID>
{
public CustomerID CustomerID{...}
...
}
If this isn't riddle then this should be either
public Customer<CustomerID>
{
public int CustomerID{...}
...
}
>The question itself reads as if you are suggesting being consistant
and using hungarian notation in every scope.

I most certainly am.
>I agree, if hungarian notation is to be used at all, it should be used
everywhere so all consumers can receive all the supposed benefits.

I couldn't agree more!
I was trying to be tongue-in-cheek, not foot-in-mouth. My problem with
hungarian notation is it has never been used to describe public
properties that point to hungarian-notated private and protected
members. This inconsistancy and the fact there is no standard makes me
question the value of the whole process especially in this day and
age.

If hungarian notation works for you that is fine and dandy. We can
agree to disagree. Now step away from the computer and take the rest
of the day off. That is what I'm doing.

regards
A.G.
Dec 9 '06 #25

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: ...
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: 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
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
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...
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
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,...
0
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...

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.