Hungarian notation in VB.NET?
Asked Answered
L

6

5

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"

Laconic answered 17/5, 2011 at 19:2 Comment(7)
Pro's, con's etc. all here: en.wikipedia.org/wiki/Hungarian_notation Voting to close because it's subjective.Demythologize
There is no need to use it in Visual Studio. It gives your plenty of hints and information on its own.Bibliotaph
Take a peek at Microsofts own recommended naming conventions for .net msdn.microsoft.com/en-us/library/xzf533w0.aspxWinthrop
If we delete the "int" (by general consensus), we have to delete the "Integer" too. That leaves "My" - the most stupid part of a variable name ever. So all variables have to be anonymous?Tameshatamez
@Ekkehard - "MyInteger" is a poor variable name even without the int on the front. The name should reflect what the value is, like currentScore or something.Transpadane
@Tameshatamez @Chris Dunaway : In case you haven't noticed, I said "e.g.", which means this is just an example..Laconic
@Simon Verbeke: I have noticed. All I want to point out: this is just the worst possible example.Tameshatamez
L
6

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).

Lanni answered 17/5, 2011 at 19:5 Comment(0)
F
7

You are correct; hungarian notation is frowned upon.

Fowler answered 17/5, 2011 at 19:3 Comment(0)
L
6

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).

Lanni answered 17/5, 2011 at 19:5 Comment(0)
L
4

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

Lacker answered 17/5, 2011 at 19:8 Comment(0)
G
1

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.

Galasyn answered 17/5, 2011 at 19:10 Comment(1)
This "answer" could easily go either way, but the tone suggests it's in favor of prefixes. I personally prefer the clarity that comes from not having my code littered with prefixes for stuff the compiler should be checking anyway. Others like not having to use the features that come with VS or something, i dunno.Hellebore
M
1

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.

Mezoff answered 17/5, 2011 at 19:15 Comment(0)
F
0

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.

Fou answered 17/9, 2017 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.