Click here to Skip to main content
15,112,662 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Why the world hates Hungarian notation? Pin
ThatThatGuy5-Apr-12 2:16
MemberThatThatGuy5-Apr-12 2:16 
GeneralRe: Why the world hates Hungarian notation? Pin
David Roh5-Apr-12 3:20
MemberDavid Roh5-Apr-12 3:20 
QuestionWhy do you need to know the type? Pin
Thomas Eyde5-Apr-12 2:41
MemberThomas Eyde5-Apr-12 2:41 
AnswerRe: Why do you need to know the type? Pin
David Roh5-Apr-12 3:18
MemberDavid Roh5-Apr-12 3:18 
GeneralRe: Why do you need to know the type? Pin
jschell5-Apr-12 10:16
Memberjschell5-Apr-12 10:16 
GeneralRe: Why do you need to know the type? Pin
David Roh5-Apr-12 10:27
MemberDavid Roh5-Apr-12 10:27 
GeneralRe: Why do you need to know the type? Pin
jschell7-Apr-12 7:22
Memberjschell7-Apr-12 7:22 
GeneralRe: Why the world hates Hungarian notation? Pin
David Roh5-Apr-12 3:06
MemberDavid Roh5-Apr-12 3:06 
Well, I am a firm believer in Hungarian and here is why - I believe that the name of a variable should instantly convey three vital pieces of information to the dev:
- it's type and I do mean type as in compiler typeof not semantics (regardless of what Charles did or did not intend)
- it's scope - is it local, a parameter, is it a passed in reference, a class level variable
- a clear indication of it's function or purpose

Different devs have their own view on how to write code; however, I believe that it's better to have a good logical reason for a belief rather than just a prejudice.

I believe that one of the reasons that Hungarian is considered bad is due to the way that many devs implement it - that is, each group uses very short abbreviations that are not clear to someone who is not part of the team so when you look at another teams code, you have to learn their abbreviations. Different teams have different rules and different ways of implementing Hungarian which make it a hassle to read another teams code.

I believe that it is not Hungarian that is the problem but rather the way that it is implemented that is the problem.

First we do very little abbreviation and only if it is an abbreviation that is so common that a noob would clearly understand it. We use longer names - yes we believe in self documenting code which means my manager should be able to read my code and understand what is being implemented in general terms (we don't however go to extremes).

If a passed in parameter is a reference that will live after a function is finished, then it is important to know that altering it can have long term consequences. If a variable is a class level variable, it is extremely important to know.

It should also be obvious that the more accurate the variable name clearly indicates it's purpose and function, the less potential there is for another dev to misunderstand or the original dev when returning to old code.

Saying that Intellisense will solve the problem or that we can mouse over a variable is not a solution because when we read code and think we understand, we rarely mouse over or use Intellisense on what we think we already understand.

Saying that Hungarian is bad because the type might change is a really weak argument - in the first place, types don't usually change that much; second, if a type does change, I certainly want to know; and lastly, with today's IDE refactoring capability, is really that hard to change a variable name (it's certainly easy for me).

We can argue about the best style to use to convey information to another dev reading our code, but I find it difficult to believe that any professional dev would say it's not important to be able to easily and quickly understand a variables:
- compiler type
- scope
- purpose

but I am sure some will. Smile | :)

It's about trying to find better ways to write reliable, easy to understand code - so what ever helps is a good thing.
GeneralRe: Why the world hates Hungarian notation? Pin
TheGreatAndPowerfulOz5-Apr-12 6:18
MemberTheGreatAndPowerfulOz5-Apr-12 6:18 
GeneralRe: Why the world hates Hungarian notation? Pin
jschell5-Apr-12 10:40
Memberjschell5-Apr-12 10:40 
GeneralRe: Why the world hates Hungarian notation? Pin
MehGerbil5-Apr-12 3:18
MemberMehGerbil5-Apr-12 3:18 
GeneralRe: Why the world hates Hungarian notation? Pin
MSBassSinger5-Apr-12 6:44
professionalMSBassSinger5-Apr-12 6:44 
GeneralRe: Why the world hates Hungarian notation? Pin
MehGerbil5-Apr-12 6:49
MemberMehGerbil5-Apr-12 6:49 
GeneralRe: Why the world hates Hungarian notation? Pin
MSBassSinger5-Apr-12 6:53
professionalMSBassSinger5-Apr-12 6:53 
GeneralRe: Why the world hates Hungarian notation? Pin
Fran Porretto5-Apr-12 3:55
MemberFran Porretto5-Apr-12 3:55 
GeneralRe: Why the world hates Hungarian notation? Pin
ferahl5-Apr-12 4:29
Memberferahl5-Apr-12 4:29 
GeneralRe: Why the world hates Hungarian notation? Pin
Fabio Franco5-Apr-12 5:39
professionalFabio Franco5-Apr-12 5:39 
GeneralRe: Why the world hates Hungarian notation? Pin
Stuart Rubin5-Apr-12 5:49
MemberStuart Rubin5-Apr-12 5:49 
GeneralRe: Why the world hates Hungarian notation? Pin
BinaryReason5-Apr-12 5:56
MemberBinaryReason5-Apr-12 5:56 
QuestionRe: Why the world hates Hungarian notation? Pin
MSBassSinger5-Apr-12 6:17
professionalMSBassSinger5-Apr-12 6:17 
GeneralRe: Why the world hates Hungarian notation? Pin
SeattleC++5-Apr-12 7:00
MemberSeattleC++5-Apr-12 7:00 
GeneralRe: Why the world hates Hungarian notation? Pin
Member 37636085-Apr-12 7:58
MemberMember 37636085-Apr-12 7:58 
GeneralRe: Why the world hates Hungarian notation? - Data Dictionary Pin
Toyist5-Apr-12 8:02
MemberToyist5-Apr-12 8:02 
GeneralRe: Why the world hates Hungarian notation? Pin
Mark Johnston (SSCGP)5-Apr-12 8:30
MemberMark Johnston (SSCGP)5-Apr-12 8:30 
GeneralRe: Why the world hates Hungarian notation? Pin
we785-Apr-12 8:56
Memberwe785-Apr-12 8:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.