File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Hungarian notation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hungarian notation " Watch "Hungarian notation " New topic

Hungarian notation

Sahir Shibley
Ranch Hand

Joined: Apr 08, 2000
Posts: 275
Why do they say that hungarian notation violates OO abstraction ?
John Wetherbie

Joined: Apr 05, 2000
Posts: 1449
This is an interesting question. Could you cite where this was stated/who they are?
I would almost consider naming guidelines and OO principles as orthogonal to each other. However, I can see where people might take the position that variables names that indicate type, etc., would not be as abstract as a variable name that is purely domain based.

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Sahir Shibley
Ranch Hand

Joined: Apr 08, 2000
Posts: 275
Right here in the style sheet 3.3 (
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
You can use the "Search" function at the upper right corner of the page to find past discussions using the phrase "hungarian notation" (or whatever other phrase you're interested in of course). Doing this, I find useful discussions here and here.

"I'm not back." - Bill Harding, Twister
paul wheaton

Joined: Dec 14, 1998
Posts: 20919

I wrote the style guide.
Hungarian notation violates abstraction because it reveals what is inside.
HN also makes code less maintainable. Suppose you want to change from and int to a long. If your variable is used 20 times, you have to change your code in 20 different places. Keep in mind that search and replace functions in editors are not always perfect.

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Sahir Shibley
Ranch Hand

Joined: Apr 08, 2000
Posts: 275
But we do use hungarian notation in Delphi and C++ .
Besides if I wanted to cast one datatype to another I would
not use the same variable to do so.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
I don't think Paul was talking about casting. Imagine the situation where a customer changes a requirement so that you must now allow for more than 256 widget types in your system. Unofortunately you have used 'byte' for the number of widget types throughout your code.
Without HN, you only have to change the declarations of the variables from 'byte widgetCount' to 'int widgetCount' and recompile. If you use HN, you not only have to change 'byte bWidgetCount' to 'int iWidgetCount' in the declarations, but also everywhere it is used. And what if you have a method 'byte getWidgetCount()'?
In general, The use of HN makes every type change during maintenance a major headache, and (IMHO) gives very little in return..

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Sahir Shibley
Ranch Hand

Joined: Apr 08, 2000
Posts: 275
Point taken. Thanks.
I agree. Here's the link:
subject: Hungarian notation
It's not a secret anymore!