473,756 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I keep missing Hungarian naming; still smart to abandon?

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 EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because those
are reserved words I have to be creative and come up with a non-ideal
alternative. Also, we have a class "Pen" which is allowed, but then can get
a little confusing (and I did say a little) with the Pen class in the
System.Drawing namespace (i.e. like when viewing Intellisense).

Now, I know I can bracket the table name but... yuk.

The main argument I hear against Hungarian is that a mouseover will tell you
the type so no need to type it in (especially since it could change). But
1) like many, I *read* code and seeing the type helps, and 2) refactoring
will allow me to easily retag my Hungarian tag with another.

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).

Thanks,
Ron

Apr 24 '07 #1
14 1548
Ronald,
Nobody is holding a gun to your head. You can really do whatever you want.
However, when you start getting into wanting to use keywords as class names,
IMHO that's really starting to swim upstream.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Ronald S. Cook" wrote:
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 EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because those
are reserved words I have to be creative and come up with a non-ideal
alternative. Also, we have a class "Pen" which is allowed, but then can get
a little confusing (and I did say a little) with the Pen class in the
System.Drawing namespace (i.e. like when viewing Intellisense).

Now, I know I can bracket the table name but... yuk.

The main argument I hear against Hungarian is that a mouseover will tell you
the type so no need to type it in (especially since it could change). But
1) like many, I *read* code and seeing the type helps, and 2) refactoring
will allow me to easily retag my Hungarian tag with another.

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).

Thanks,
Ron

Apr 24 '07 #2
Ronald,

I don't thing you should leave your Hungarian friend behind if it makes your
code more readable and easy to understand to you and people that use it.
However if this gets in a way, say this is code that you ship to others to
use and they have problems with it you should consider using something that
is confortable for all of you.

I personaly have been using Hungarian notation for a long time and I still
use it for my private fields. At the very end I believe if the name of the
variable is well chosen (descriptive enough) couple of letters in the
begining won't hurt anyone.

At least this is what I think.
--
Stoitcho Goutsev (100)

"Ronald S. Cook" <rc***@westinis .comwrote in message
news:O0******** ******@TK2MSFTN GP05.phx.gbl...
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 EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because
those are reserved words I have to be creative and come up with a
non-ideal alternative. Also, we have a class "Pen" which is allowed, but
then can get a little confusing (and I did say a little) with the Pen
class in the System.Drawing namespace (i.e. like when viewing
Intellisense).

Now, I know I can bracket the table name but... yuk.

The main argument I hear against Hungarian is that a mouseover will tell
you the type so no need to type it in (especially since it could change).
But 1) like many, I *read* code and seeing the type helps, and 2)
refactoring will allow me to easily retag my Hungarian tag with another.

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).

Thanks,
Ron

Apr 24 '07 #3
Ronald S. Cook wrote:
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.
And because you've abandoned BCPL? Excellent. :-)
But things keep coming up that make me miss my little 3-character prefixes.

I'm fine with EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because those
are reserved words I have to be creative and come up with a non-ideal
alternative.
"event" is a keyword (although for classes, you normally start with an
upper case character - Event is not a keyword).
I don't believe "User" (or "user") is reserved in any context.

If you *really* want to use reserved words as names, you can prefix them
with '@' - for example:

string @string = "string";
Also, we have a class "Pen" which is allowed, but then can get
a little confusing (and I did say a little) with the Pen class in the
System.Drawing namespace (i.e. like when viewing Intellisense).
I think it would still be a little confusing if you prefixed it with
'some random characters' :-)
The solution to stop that confusion is to refer to types by their full
names when things could be confusing.
The main argument I hear against Hungarian is that a mouseover will tell you
the type so no need to type it in (especially since it could change). But
1) like many, I *read* code and seeing the type helps, and 2) refactoring
will allow me to easily retag my Hungarian tag with another.
I think the best argument against it is that we have a type system these
days. Also, you only have to hold your mouse over a variable if its type
isn't clear (which 'should' never happen).

Another argument is that plenty of programmers don't use Hungarian
notation (I've never used it - I wasn't programming in the days of BCPL
and it became pointless when C was invented) and it makes reading your
code more difficult for no apparent reason.

Alun Harford
Apr 24 '07 #4
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:O0******** ******@TK2MSFTN GP05.phx.gbl...
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.

[...]

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).
IMHO, the biggest argument for someone who likes Hungarian to switch to the
..NET style is if they are writing code that is published to the general .NET
community. For example, you're writing a library that other people writing
..NET will be using, and so you all of the public API for that library
follows the .NET coding convention.

Even then, there's no need to change the internal parts of the code. Just
keep the public part consistent with the .NET standards so that other .NET
customers can more easily learn your API. (And frankly, if your library is
useful I doubt anyone would have much justification to complain even if you
did follow Hungarian conventions for the public part of the API).

Other than that, seems to me that if Hungarian works for you and you like
it, there's no reason to stop using it internally. I continue to use
Hungarian in my .NET code, and it provides all of the same benefits it
always has.

I certainly don't see the point in switching your coding conventions just
because Microsoft has changed their mind about what the "standard" is. If
you do switch to the .NET conventions internally, you should do so because
there's some real benefit to *your* development team in doing so.

Pete

Apr 24 '07 #5
Peter Duniho <Np*********@Nn OwSlPiAnMk.comw rote:

<snip>
I certainly don't see the point in switching your coding conventions just
because Microsoft has changed their mind about what the "standard" is. If
you do switch to the .NET conventions internally, you should do so because
there's some real benefit to *your* development team in doing so.
While I take your point, I think that consistency is a benefit in and
of itself. It would look very odd to, say, have all your own method
names in the_c_style_of_ naming_with_und erscores and still be calling
FrameworkMethod sWithPascalCasi ng. It just looks uneven and
inconsistent.

As you say though, there's nothing to stop you from naming variables
however you like.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 24 '07 #6
Ronald S. Cook wrote:
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 EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because those
are reserved words I have to be creative and come up with a non-ideal
alternative. Also, we have a class "Pen" which is allowed, but then can get
a little confusing (and I did say a little) with the Pen class in the
System.Drawing namespace (i.e. like when viewing Intellisense).

Now, I know I can bracket the table name but... yuk.

The main argument I hear against Hungarian is that a mouseover will tell you
the type so no need to type it in (especially since it could change). But
1) like many, I *read* code and seeing the type helps, and 2) refactoring
will allow me to easily retag my Hungarian tag with another.

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).

Thanks,
Ron
In my opinion, there is no good reason to use hungarian notation for
data types in a type safe language.

The original intention of the hungarian notation was to convey crucial
information about the data that could not be done in any other way. In
the beginning this was used in BPCL, that only has one data type, to
specify the intended data type of a variable. For some reason this
spread to other languages, and is today widely regarded as the proper
use of the hungarian notation, and is used even in type safe languages,
eventhough it is not at all in line with the original intention.

There are other uses for hungarian notation that might be useful, like
specifying that a variable contains unverified user input, or
differentiating between horisontal and vertial coordinates.

If you personally feel that you need to use hungarian notation to
specify the data type in order to write good code, feel free to do so.
Then at least you are doing it by choise, and not just beacause everyone
else is doing it. :)

--
Göran Andersson
_____
http://www.guffa.com
Apr 24 '07 #7
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
Peter Duniho <Np*********@Nn OwSlPiAnMk.comw rote:

<snip>
>I certainly don't see the point in switching your coding conventions just
because Microsoft has changed their mind about what the "standard" is.
If
you do switch to the .NET conventions internally, you should do so
because
there's some real benefit to *your* development team in doing so.

While I take your point, I think that consistency is a benefit in and
of itself. It would look very odd to, say, have all your own method
names in the_c_style_of_ naming_with_und erscores and still be calling
FrameworkMethod sWithPascalCasi ng. It just looks uneven and
inconsistent.
I have always had that issue, whether I used Hungarian or not. Even in the
olden days, the early Mac *and* Windows API did not have a 100% consistent
naming convention, making it very hard to match my code to theirs (and while
you could come close in the earliest versions of their APIs, every time some
new technology came along, it diluted whatever API-wide convention
existed...see DirectX and Quickdraw 3D for examples). Throw third-party
libraries into the mix, and all bets were off.

Personally, I just don't sweat it. I can easily deal with having my code
all follow one convention, while using an API that uses a different
convention. Consistency does have value, but IMHO internal consistency is
much more important than external consistency (that is, where two
independently developed modules meet, it is acceptable to have some naming
inconsistencies somewhere, and in fact is nearly unavoidable even in today's
development community). And there are other issues that rank much higher in
priority.

If you don't agree, then by all means spend your time making your code look
just like everyone else's. But for those of us who find real added value in
Hungarian (or any coding convention different from the .NET convention, for
that matter), making one's own code look just like someone else's code is
pretty low on the priority list. I don't disagree that doing so has value,
I just don't think it deserves much weight when other factors are also to be
considered.

Pete

Apr 24 '07 #8
"Göran Andersson" <gu***@guffa.co mwrote in message
news:uM******** ******@TK2MSFTN GP04.phx.gbl...
In my opinion, there is no good reason to use hungarian notation for data
types in a type safe language.
It seems obvious to me that the question of whether there's a good reason
*to* use Hungarian isn't relevant here. Obviously the OP prefers it, and
has his own opinions supporting that preference.
The original intention of the hungarian notation was to convey crucial
information about the data that could not be done in any other way. In the
beginning this was used in BPCL, that only has one data type, to specify
the intended data type of a variable. For some reason this spread to other
languages, and is today widely regarded as the proper use of the hungarian
notation, and is used even in type safe languages, eventhough it is not at
all in line with the original intention.
As anyone who has read these threads here in the past probably knows, I
disagree. If and when a language provides a way for me to *easily* and
*conveniently* typedef (for example) an "int" to be my own typesafe data
type that the compiler will prevent me from using in any other context, then
perhaps we can talk about whether Hungarian is no longer useful.

But until then, there are still examples too numerous to count of places
where a compiler will happily accept code that is semantically incorrect.
Hungarian guards against this (and provides other benefits as well, as you
mention...it's a mistake to think that type-checking is the only benefit of
Hungarian).
There are other uses for hungarian notation that might be useful, like
specifying that a variable contains unverified user input, or
differentiating between horisontal and vertial coordinates.

If you personally feel that you need to use hungarian notation to specify
the data type in order to write good code, feel free to do so. Then at
least you are doing it by choise, and not just beacause everyone else is
doing it. :)
I can certainly agree with that. :)

Pete

Apr 24 '07 #9
if you miss it.. then use hungarian

On Apr 24, 6:15 am, "Ronald S. Cook" <r...@westinis. comwrote:
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 EmployeeFirstNa meLabel instead of lblEmployeeFirs tName, 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 names. But, because those
are reserved words I have to be creative and come up with a non-ideal
alternative. Also, we have a class "Pen" which is allowed, but then can get
a little confusing (and I did say a little) with the Pen class in the
System.Drawing namespace (i.e. like when viewing Intellisense).

Now, I know I can bracket the table name but... yuk.

The main argument I hear against Hungarian is that a mouseover will tell you
the type so no need to type it in (especially since it could change). But
1) like many, I *read* code and seeing the type helps, and 2) refactoring
will allow me to easily retag my Hungarian tag with another.

Can someone please make me more comfortable leaving my Hungarian friend
behind? I'm not convinced that it's the best decision (from an app dev
standards policy in our shop).

Thanks,
Ron

Apr 24 '07 #10

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

Similar topics

66
3710
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
3836
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
24
2375
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? 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:
6
4069
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!
3
1596
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
12
3596
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
9462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10046
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
9886
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
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...
0
6542
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();...
1
3817
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
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.