Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Dutch Notation?

Author
Message
Shady 2005 Simpson
21
Years of Service
User Offline
Joined: 26th Aug 2003
Location: Newcastle, England
Posted: 9th Oct 2003 22:13
Hi,
I can't remember who said it (IanM I think), but someone warned me before I started to learn C++ not to learn "hungarian notation", could someone please tell me what this is.

Just to make sure I'm not,

Thanx.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Oct 2003 23:27
when naming variables you preface the name with the variable type like:

strCustomer as String
intSomeValue as Integer

so in your code, later, you know a variable's type by looking at it's name. Microsoft is actually advocating not using H-Notation when using .NET because the IDE has a feature that shows a variable's type when moused over. Whatever, I still use, and advocate using Hungarian Notation but before I get flamed for preaching I'd say do whatever makes you comfortable.

-RUST-
Shady 2005 Simpson
21
Years of Service
User Offline
Joined: 26th Aug 2003
Location: Newcastle, England
Posted: 10th Oct 2003 00:05
Thanx for your help guys,

btw, the title is supposed to say hungarian notation not dutch
Sonic
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: UK
Posted: 10th Oct 2003 01:20
Me view is that its bad form for microsoft to try to dictate the way programs are coded. I think H notation is good, precise and the fact it originated from a Microsoft employee is of no consequnce.

Not everyone writing code is using (and paying $$$) for Visual Studio, for example you might be writing some VB.NET or ASP.NET in notepad or dreamweaver or whatever.

Of course each to his own but every coder will develop a certain style as they practice and I can see little wrong with a "convention" that encourages standardisation of code, clarity and self documentation. Without these things, picking up someone elses code would turn back to being the nightmare it always used to be before.

"My ignorance amuses me..."
http://www.victory-road.co.uk
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Oct 2003 01:27
i use the variable notions no matter the language i'm using.
for smaller projects it fine and for individual values its fine not to use them...

but when you have over 5,000 lines of code just for a simple tic-tac-toe game you want to be able to know what the values variable notion is at a glance

this kinda stuff is just inherint really within any data descriptive language - its why ASM is a bugger to use at times, because you don't really have the space or length to add dscriptive names and such.
but its best not to get carried away because exceptionally long names are a pig to type in.

Ian T
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th Oct 2003 02:25
Microsoft's dictation there is just another of their little tactics to get people to keep using their software. You stop using hungarian dictation, it'll harm your coding-- in anything but the programming enviorments they want you to use.

--Mouse: Famous (Avatarless) Fighting Furball

A very nice %it, indeed.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Oct 2003 02:47
Hah. Hungarian notation ... *spit*. You've triggered a pet hate of mine

Start with a float 'fValue', decide you need the extra precision of a double, and then go mad with search/replace to change every occurence to 'dValue', hoping you don't accidentally change something you shouldn't.

Self-documentation of variables comes from their names - not their type prefixes. If you can't tell what you variable holds from it's name, you haven't named it right.

Also, most editors will give you tooltips of the variable type now too

Have a read of this for a discussion on Hungarian notation - it's centred around C++, but most of the arguments given are valid for most languages : http://www.cuj.com/documents/s=7989/cujcexp1911hyslop/
Read from the line starting "Warts!" ... no, really
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 02:54
Yep, totally agree with IanM. Descriptive variable names is the key (and tooltips, ok).
In Delphi, for example, the only common prefixes are T for types (structures,sets,classes) and P for pointers to types.


Quote: "its why ASM is a bugger to use at times, because you don't really have the space or length to add dscriptive names and such."

Erm, why is this?

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Oct 2003 03:09
Some older assemblers have a limit on the size of labels, but this is far less of a problem nowadays (eg MASM has 32 char labels IIRC).
Sonic
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: UK
Posted: 10th Oct 2003 03:16
But surely, by using a bit of "Hungarian" you get the best of both worlds, when you read it later you know what it's for (the descriptive name) and what type it is (the Hungarian bit)?

"iPlayerScore" then becomes completely clear, an Integer that represent the Player Score - you don't wanna pass it to a function that is expecting a float. "m_iPlayerScore" is even better, you can see its a member variable for the player score without even thinking about it.

In DarkBASIC you might have "PlayerName$" which is serving the same purpose telling you purpose and type so you don't need anything else but I don't buy the tooltip argument as if you're looking at a printout of code from a book, tutorial whatever then that information is lost.

In some languages that are not strong on typing, like Perl or something I'd agree it's not important but for me, anything you can add that makes your code clearer is a good thing.

"My ignorance amuses me..."
http://www.victory-road.co.uk
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 03:42
Quote: "Some older assemblers have a limit on the size of labels"

Yes, I know. But some older Basic, Pascal versions probably most other languages had these limitations too- simply because of the limited memory that computers had those days.

Quote: "(eg MASM has 32 char labels IIRC)."

No, at least not the current version.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Oct 2003 05:08
the label names might be longer now, but when your programming using the register and op codes which names are around 2-5 letters long it makes it seem very cumbersome to have lengthy names.

i use the Variable denomination simply because i find it hard to remember every little variable i make. Particularly when your making larger games with complex engines, although you'll only be working on one little bit at a time just having some form of overview to what it is

lp (strings), f (float), i (integer), p (pointer), v (vector), etc...
although i can easily just dismiss the standard types - when it comes to my structured types its good to keep track.

although v could stand for vector2,3,4 and even be either an interger of float vector, its good to know that it is a vector type then i can look at it at a glance and remember exactly what the entire function is for

i know alot of people don't like that sort of thing, and i've now got out of the habit of labelling everything which i got when i first started, i now use it as a reminder system as my memory isn't as good as most peoples.

DrakeX
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 10th Oct 2003 07:36 Edited at: 10th Oct 2003 07:39
i've never made anything big enough in C++ that required me to use any kind of notation

then again, if you split your code up into many small functions, you rarely have to worry about overlapping variable names anyway, and so you never really run into this problem. at least that's what's worked for my tiny projects

funnily (just made that word up), there is also reverse polish notation, which is a way to order mathematical expressions so you don't need parentheses. what's with programmers and naming things after countries?

a yoshi's island penguin smilie. oh my god, i am in heaven.

stop looking at me!

Login to post a reply

Server time is: 2024-11-24 00:56:19
Your offset time is: 2024-11-24 00:56:19