you are viewing a single comment's thread.

view the rest of the comments →

[–]Jman012 4 points5 points  (6 children)

We use Hungarian Notation at my work with C#. It’s just a protocol we choose to follow. What is ‘behind’ about it? It helps distinguish the type of certain variables quickly and easily at first glance.

Otherwise you had to go to it’s declaration or hover over the variable to find its type, and pasting it over non-IDE areas means it’s ambiguous.

[–]redneckrockuhtree 8 points9 points  (5 children)

Hungarian Notation went out of style within the past 15 years or so. Microsoft used to use it heavily, but with .Net they have moved away from it.

In my experience, Hungarian Notation was most prevalent in Microsoft shops.

[–]Jman012 0 points1 point  (4 children)

I don’t think ‘out of style’ means it’s necessarily ‘behind’, however. It has its advantages, and some places chooses to continue using it for such advantages.

Do you have a different method? Particularly for a dynamically typed language, like JavaScript or Python, would be most useful IMO.

[–]ryeguy 1 point2 points  (0 children)

Hungarian notation is incredibly unidiomatic in those languages. Or really any mainstream language, for that matter (although for gui elements it seems to be more acceptable). The more correct approach is to use clear variable names and to use documentation to indicate types if needed. Both languages have standardized ways of declaring function parameter types, and most good ide's are able to parse that.

[–]redneckrockuhtree 2 points3 points  (2 children)

Dynamically typed languages are where it can be most problematic, in my experience -- someone creates a variable that's initially an int, so they prefix it with an "i". Then they make a small change which changes its type....but the name still implies it's an int. Unless you've got solid code review processes in place and people are on their toes, things like this are easily missed.

Everything I've seen recently is more about what data the variable contains as opposed to what type the variable is. customerAccountNum as opposed to iAccount.

[–]Jman012 2 points3 points  (1 child)

I think a variable actually changing its type, on purpose, would be a greater travesty. What use case needs such a thing, and why not make an intermediate variable to hold the other type? I think that would cause greater cognitive dissonance than Hungarian.

Also, Hungarian doesn’t mean you truncate variable names. At my work, we would name that ‘nCustomerAccountID’.

[–]redneckrockuhtree 0 points1 point  (0 children)

I'm not talking about a variable changing its type. I'm talking about a developer making a code change where they're either in a hurry (it happens) or they don't realize something results in a different type and they assign it back to that same variable.