Why the world hates Hungarian notation?
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
Well I've got to say that between
lAccNum
andaccountNumber
, the latter clearly indicates what the type is.Regards, Nish
My technology blog: voidnish.wordpress.com
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]
-
Well I've got to say that between
lAccNum
andaccountNumber
, the latter clearly indicates what the type is.Regards, Nish
My technology blog: voidnish.wordpress.com
Nish Sivakumar wrote:
accountNumber
, the latter clearly indicates what the type isYou've obviously not worked on some of the databases that I've had to support.
...
,AccountNumber VARCHAR(30) NOT NULL
...Though to your credit, hungarian notation probably wouldn't help things out, much. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
I worked on a project where one of the data types changed. Then you have to go through the code and change the notation everywhere that variable is used. Pretty easy with search and replace, but doesn't need to be done if you just use proper naming.
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
I read 'nation' to start with and I was ready with :mad:, but I'll forgive you. This once. Hungarian notation works, as you say, well and you always know what the data type is. If you don't use it then you need to go back to the point in the code at which the variable was defined. This was indeed a problem using old fashioned non-contextual editors. With the use of modern IDE's, you can easily see the data type because of IntelliSense. I personally do not use Hungarian notation anymor, but I understand and appreciate its usefulness.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
It's far too easy to get really anal over naming conventions. Whilst I no longer use Hungarian I can't condemn anyone that does. Why? Because there is nothing wrong with it as long as its use is applied consistently throughout the project. Yes, it might look a little weird to me, but my code might look weird to you; doesn't mean it's bad code; just means we have differing naming convention preferences. Do what you want as long as it does no harm.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]
This has always bee my point of view on Hungarian. If you're using Hungarian to show you type info (i.e. compiler types, not semantic types), then you're using Hungarian wrong. Wrong Hungarian = bad. Right Hungarian = good. I currently don't trust anyone on my team to write "right Hungarian", though, so we outlaw it altogether at my workplace.
-
It's far too easy to get really anal over naming conventions. Whilst I no longer use Hungarian I can't condemn anyone that does. Why? Because there is nothing wrong with it as long as its use is applied consistently throughout the project. Yes, it might look a little weird to me, but my code might look weird to you; doesn't mean it's bad code; just means we have differing naming convention preferences. Do what you want as long as it does no harm.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
-
I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
VuNic wrote:
I'm finding it difficult to review the code in notepad.
IMHO that's your problem. Sure, Hungarian notation may allow you to easily identify the type of a variable (assuming the type hasn't changed since the variable was named), but I recommend using a tool like VS to do a proper code review. /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Well I've got to say that between
lAccNum
andaccountNumber
, the latter clearly indicates what the type is.Regards, Nish
My technology blog: voidnish.wordpress.com
Nish Sivakumar wrote:
...
accountNumber
, the latter clearly indicates what the type is.What type is it: numeric (long, int, double) or alphanumeric?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
If it suits what you're doing then go for it: don't listen to all the crazies and their pedantic rants about how stuff should get done.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
As an aside, the .NET world is vehemently opposed to Hungarian notation yet the prefix _ is ok. WTF. I would rather use m than _ any day of the week. At least m stands for something. Of course, the reason the _ is even necessary is because of VB.NET.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
Nish Sivakumar wrote:
accountNumber
, the latter clearly indicates what the type isYou've obviously not worked on some of the databases that I've had to support.
...
,AccountNumber VARCHAR(30) NOT NULL
...Though to your credit, hungarian notation probably wouldn't help things out, much. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
Yeah, account number was probably a bad choice for my example :-)
Regards, Nish
My technology blog: voidnish.wordpress.com
-
Nish Sivakumar wrote:
...
accountNumber
, the latter clearly indicates what the type is.What type is it: numeric (long, int, double) or alphanumeric?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
DavidCrow wrote:
What type is it: numeric (long, int, double) or alphanumeric?
If I see
accountNumber
, I'd automatically assume anInt32
(.NET).Regards, Nish
My technology blog: voidnish.wordpress.com
-
I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]
Only one 5 available, sorry. That is a very good example of doing things for the right reason. Bookmarked. :thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
Using meaningful variable names reduce the need to artificially decorate variable name. And in 2012, intellisense type technology makes it easier to keep tab of what type are the variables you are using. IMO, using notepad to do code-review is counter-productive.
Watched code never compiles.
-
Using meaningful variable names reduce the need to artificially decorate variable name. And in 2012, intellisense type technology makes it easier to keep tab of what type are the variables you are using. IMO, using notepad to do code-review is counter-productive.
Watched code never compiles.
Actually I intentionally put that as Notepad though I would be using an IDE for the code review. Because to me both IDE and notepad would mean the same unless I copy the entire project for the review.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
-
I read 'nation' to start with and I was ready with :mad:, but I'll forgive you. This once. Hungarian notation works, as you say, well and you always know what the data type is. If you don't use it then you need to go back to the point in the code at which the variable was defined. This was indeed a problem using old fashioned non-contextual editors. With the use of modern IDE's, you can easily see the data type because of IntelliSense. I personally do not use Hungarian notation anymor, but I understand and appreciate its usefulness.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
Nagy Vilmos wrote:
I personally do not use Hungarian notation anymor
Nagy Vilmos? ;)
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
For me, I used to use Hungarian when I was coding in MFC and C++. Now that I have been using .NET I don't use it for a few reasons. The modern IDE can show you the type very easily. People have changed types and then were lazy to rename the variables. Names like these are like specs, they get out of date pretty quickly. Some people on my team use the old m_ or just m to say member variable. One person just uses an _ but at the end of the name, not the beginning. So typically since it is a religious war when it comes to things like this or where he proper place to put the curly braces, we typically just state to follow the coding convention that the person wrote the code in. If you cannot understand it, then I really don't want you on my team anyways. ;) Of course taking home 300 lines of code from your work is actually concidered IP theft where I work unless you have a company laptop and can VPN in. That and then picking notepad to view the code is just not right. At least get Notepad+.
Steve Maier
-
I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
Because most people do it incorrectly. The guy, Simonyi, who invented Hungarian notation meant for the names of variables to carry the kind of thing it is, not its type. So, instead of
int iRowScr, iColScr.
List ilBal;you'd have
int rwScreen, colScreen;
List Balances;He never intended for the variable name to carry the underlying type, but rather the name should be informative of what it is.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun