Declaring variables in programming

Joined
Mar 31, 2008
Messages
12
Reaction score
0
Points
1
Location
East Coast, United States
Your Mac's Specs
Macbook 2.1 Core 2 Duo w/ 1GB Ram
I am putting this out to those of you that do a lot of coding. I am in a Visual Basic course right now, against my will ;(, and my teacher is having us declare variables with Hungarian notation. I have been coding C and Bash shell scripts in Linux for a few years and have never done it, nor have I ever seen it in a book.
For those that may not know what this is, it is declaring the variable type in the name; for example dblNumberOne or intTempOne. I was just curious, this teacher seems to be pretty good but his code sometimes makes no sense or he do things certain ways, just because that is the way you are supposed to do them, giving us no reason for it.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
It seems to have become popular within Microsoft and effectively exported from there. Being your instructor is teaching VB, it should be no surprise he is using it.

It isn't right or wrong, but can be very helpful. I suggest you stay open to the idea. You might find the idea helpful in the future. It is a quick way recognize the type you are using and if it makes sense in the context you are about to place the variable in. Also, when it is expected that others with be working on the code, it may be a good convention to follow.

Class should have opportunities for two way discussion, so I suggest you note those times where things don't make sense and either raise the question during class or discuss it later one on one. Be proactive.
 
Joined
Mar 9, 2004
Messages
9,065
Reaction score
331
Points
83
Location
Munich
Your Mac's Specs
Aluminium Macbook 2.4 Ghz 4GB RAM, SSD 24" Samsung Display, iPhone 4, iPad 2
Hmm, I hadn't heard of that convention before, but when you think about it I suppose it could make a lot of sense...

It would certainly help to avoid type mismatch errors :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top