Question

Our programming teacher taught us to use the Hungarian notation (e.g. intMyInteger, strMyString,...) while programming.

But I have heard somewhere this isn't actually used in the professional world. Is this true?

Edit: I just found out this is actually "Leszynski"

Was it helpful?

Solution

True. Modern IDE's, misunderstanding of application, issues with usage, etc.... have essentially killed it. That doesn't mean you won't find it out there potentially but I would avoid using it and get use to camel casing and pascal casing.

Microsoft has recommendations on naming standards. They use it in .Net Framework and many follow this.

MS also has the All-In-One Code Framework site that has documentation and samples to help further this thought and other best practices (from MS's point of view).

OTHER TIPS

You are correct; hungarian notation is frowned upon.

This article by Joel will provide you some useful information on Hungarian notation.
http://www.joelonsoftware.com/articles/Wrong.html

We just talked about this at the place that I work doing programming. What we decided is that it is more important to have names that are very clear and easy to understand rather than save a couple characters.

AFAIK, it was used expecially under Windows. Hungarian notation comes from software engineer Charles Simonyi, who was a Microsoft employee at the time. By now, it is mainly fallen in disuse, as you can see. In my opinion, I agree with Stroustroup as he says that the utility of hungarian notation is only for weakly typed languages, but it's confusing in OOP languages and in general is a limit to abstraction.

When you develop your art (I consider coding an art), you'll find that you'll establish your own naming conventions. Like a guitar player who adopts certain styles from his / her heroes.

I haven't found any "official" naming convention recommendation that would suit me perfectly.

I think readability is the most important subject.

My personal rules are:

Private variables should start with _. Variables should use an abbreviated hungarian style, like s for string, i for integer, b for boolean, etc.

Variables passed to a function always start with an u for me, and they have a very distinct name, like uCountItemsInAList so that the the hungarian prefix doesn't have to be used because the type is relatively clear from the naming already. And variables passed to functions are already likely to be misinterpreted easily, so a long, very descriptive name is allowed in my opinion.

When I use a class only within a function, if the function is short, I start the class name with an n.

I code like 16 hours a day, and I do it manically, so I think my answer can't be so "wrong". Although this topic is very subjective, I think readability can be considered a key factor, and my way of coding contains parts of all top coders that I was able to study so far.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top