Variable Naming Convention

GaneshParam

New member
Joined
Jul 4, 2005
Messages
4
Programming Experience
5-10
I am using "ctrl" as prefix for naming my windows controls instead of Hungarian Notation. e.g. ctrlName for Name textbox control. Is it better?
---------------------------------------
I have a Persistent Class e.g. Person.
Public Class Person
Dim _name as string
Dim _age as int
Public Property Name
...
End Property
Public Property Age
...
End Property
End Class

Now I want to use Person Class as parameter in a method. can I use the same name for Parameter as class name.
e.g.
Public Function GetPersonDetail(person as Person) as boolean
...
End Function

I use the same for defining variables within a class.
e.g.
Public Sub SetPersonDetail()
dim person as Person
msgbox (person.Name)
End Sub

Though the above codes compiles and works without any runtime errors is it the right way to develop .net if not can you suggest a better way.

Ganesh P. Thanks for your help in advance
 
Hungarian notation is adding a prefix that is an abbreviation of the object's type, so "ctrl" IS Hungarian notation. Microsoft recommends against using Hungarian notation and, personally, I hate it. It has outgrown its usefulness as there are just too many types for the prefixes to be especially meaningful. My blood boils when I see "obj", which is completely pointless. The sophisticated IDEs available these days, with Intellisense and Tooltips on mouse-over make Hungarian notation pointless. It's generally not a great idea to use the class name for a variable of that type. You'll find that the .NET Framework will use the same name for properties, which will generally be qualified with the object name, but using the class name for local variables can be confusing. I do it sometimes but generally only when the code block is very short.
 
can I use the same name for Parameter as class name.

While technicaly you can... it's not a good idea.

-tg
 
Back
Top