Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

That doesn't seem to make sense.

In local variable, we sort of know the type anyway. It's local. We're working on it.

Yet in function name or global variable, the definition is very far away on other files. It seems that hungarian notations make far more sense there.

For example, in objective-c I used this

+(CGFloat) fHeightOfNavigationController

So when I want to know the height of navigation controller, I will need to press a button that specify the function.

What's the button? What's the name of the function. Is it heightOfNavigationController? Is it NavigationControllerHeight? Is it navHeight?

I don't know which letter I should type first to activate the autocomplete. But I know the function is float.

So I just type f...

Tada... I got fHeightOfNavigationController in autocomplete.

Yet I don't think this is how most people use hungarian notation.

Why?

share|improve this question

closed as primarily opinion-based by gnat, Bart van Ingen Schenau, Kilian Foth, GlenH7, MichaelT Mar 13 at 0:00

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

10  
People still use hungarian notation? –  thorsten müller Mar 12 at 8:31
1  
    
What happens if you don't know the return type, in Objective C, every library function have a meaning full name like autorotateToInterfaceOrientation,viewWillAppear. –  Midhun MP Mar 12 at 8:37
1  
1  
The problem with this in one sentence: But I know the function is float.. Your 'advantage' requires you to know the metadata you're assigning to the function, thus proving it does not need to be assigned. –  Phoshi Mar 12 at 9:07

2 Answers 2

hungarian isn't used all that much anymore for various reasons, most importantly code completion software solves most of the problems hungarian aimed to solve.

also hungarian in it's original format (apps hungarian) specified the usage of the variable instead of just the type (systems hungarian). Meaning that the coordinates of the mouse cursor on the screen would be scrXmouse and scrYmouse instead of imouseX and imouseY.

A function to transform it to local view could then be named translateScrXScrY2LocXLocY(int srcX, int scrY, int* locX, int* locY); then you immediately see when you made a mistake in variable order

share|improve this answer
1  
hmm, IMO the fact that it makes for stale names when refactoring is far more important than code completion. Got to love LPFSTR in the Win32 and Win64 APIs when long pointers and far strings have been meaningless concepts for something like 20 years. –  jwenting Mar 12 at 10:49

People don't use Hungarian notation any more, its a nice idea that's had its day.

Everyone knows the problem with Hungarian - apart from making your names garbled with a special code - if you change anything, you then also have to change the name to match. So if you have a function called iGetCustomer and one day you want to return more than just an integer, you have to change everywhere the function is called to be cstGetCustomer which is just a nuisance. (though, obviously, you have to change everywhere its used anyway as you've changed the return type!)

Still, its just one of those fashion things, nobody uses it any more, instead they use a form of name coding where some types are notated differently (eg interfaces with I prefix, exception classes with 'Exception' suffix etc).

WRT intellisense, many people type this. and then let the system present a list to pick from. If you also name according to function rather than return type, you can then group your functions (eg GetX, GetY, etc will all appear together whereas iGetX and fGetY will not).

share|improve this answer
4  
Not quite true. People do still use Hungarian notation. Systems Hungarian has problems. Functional Hungarian has valid uses. –  Marjan Venema Mar 12 at 8:51
    
and it never was a nice idea anyway, especially systems hungarian (functional has something going for it but makes refactoring very hard, especially in public APIs). –  jwenting Mar 12 at 10:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.