Re: .NET naming conventions
It depends, hungarian notation was not developed for that purpose. It was actually developed to show the state of different variables like cleanDataAdaptor, dirtyDataAdaptor. www.joelonsoftware.com has more on it I belive.
Having said that I do it with controls but not variables.
There is no right or wrong really.
Re: .NET naming conventions
I just want to add also. Alot of places will have their own naming conventions in house and some have none. One of the chief principals I learned regarding variables was to declare close to where I use them. This means that I usually do not need to have any sort of naming convention for them as the declaration is never far from the usage point.
Ive only noticed issues in other peoples code when it started to sprawl which it should not do in the first place. Good code is easy to read naming convention or not and may not even need comments as it is self explanatory.
Re: .NET naming conventions
Quote:
Originally Posted by Blakk_Majik
...I'm thinking it was used alot in VB6 because it didn't have the advanced intellisense that Visual Studio has.
Sorry but that is laughable. :)
"Hungarian notation" aka "Apps notation" was created long before there was VB (any version at all).
Major advantage of that technic was for languages that didn't have any data types - programmer could recognize variable "type" by simply adding prefix (str, int, etc).
Back then (some 30 years ago) it was a big deal tough...
Unfortunately "Hungarian notation" became industry standard - I'm saying "unfortunately" because it got to a point when it was mandated to be used by absolutely stupid management (basically people who had very little to do with programming at all).
Also, lots of people got into a habit of using prefixes... That's the short story behind it.
At any rate however, naming variables should at least make some sense - don't name them a,b,c or aa, ab, ac - make it meaningful (something like oldCustomer, newCustomer, etc)...
Re: .NET naming conventions
Re: .NET naming conventions
Quote:
Originally Posted by Blakk_Majik
I wanted to ask this question before I went further in the development process. I ask now, because someone told me I was doing it wrong.
Yeah, me too and me too.
I still use it...
Re: .NET naming conventions
I dropped the Hungarian then .NET came out. When I joined this company there were very loose 'general' conventions but over time, we simply got the Microsoft recommended guidelines as our standards.
http://msdn.microsoft.com/en-us/library/ms229002.aspx
For the controls, the conventions are vaguer but what I use now is something like this
TextBoxFirstName
DropDownListCountries
It's pseudo-Hungarian in a way, isn't it? But they're capitalized because they're effectively public properties and at the same time it helps in intellisense if you have several textboxes on the form.
I'd say you should drop the prefixes. Others say that 'good code is readable' and so you shouldn't need the prefix to indicate the type but I don't see the point of that either. I don't think it matters what the type is, just make it something logical that indicates what it's doing in the code.