|
-
Nov 13th, 2008, 05:41 PM
#1
Thread Starter
Addicted Member
.NET naming conventions
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.
One of the things I carried over from VB6 was the Hungarian notation. To me, it just makes things look much cleaner when you're reading someone's code.
So, is this still standard practice, or should I drop the prefixes? Please note, I'm only talking about variable declarations (strVariable, intVariable, etc.). I'm staying with the control conventions (txtTextBox, ddlDropDownList, etc.) until someone threatens to set me on fire for doing so.
I'm thinking it was used alot in VB6 because it didn't have the advanced intellisense that Visual Studio has.
If my post helped you, please rate it!
Languages: VB/ASP.NET 2005, C# 2008,VB6
Databases: Oracle (knowledge not currently in use), DB2
FROM Customers
WHERE We_Know_What_We_Want <> DB.Null
SELECT *
0 rows returned
-
Nov 13th, 2008, 06:00 PM
#2
Frenzied Member
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.
-
Nov 13th, 2008, 06:06 PM
#3
Frenzied Member
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.
-
Nov 13th, 2008, 09:11 PM
#4
Re: .NET naming conventions
 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)...
Last edited by RhinoBull; Nov 13th, 2008 at 10:06 PM.
-
Nov 14th, 2008, 06:10 AM
#5
Frenzied Member
Re: .NET naming conventions
-
Nov 14th, 2008, 12:09 PM
#6
Re: .NET naming conventions
 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...
-
Nov 14th, 2008, 12:30 PM
#7
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|