Main Site Documentation

Syntax question


#1

I see some codings that use:

motors instead of motors …what does "" do , is it for some purpose? I tried searching, but didn’t really have a term to search for…I only see this used once in a while, perhaps it has some significance.


#2

That’s just a naming convention. I use the underscore myself to denote top level private variables that are use inside the class. Others use m at the start of the variable. All just a matter of preference really as long as the code is readable.


#3

I use m_ which I’ve been told is a C++ convention, even though I was doing it long before I ever wrote any C++ code.


#4

When I went to .NET training, the convention that was taught there was to use the underscore “" or "m” for the private fields in a class, and to drop those prefixes for the public accessors to those fields.


#5

Nice brief doc on one of the used naming conventions:

http://www.dofactory.com/reference/csharp-coding-standards.aspx


#6

I agree with Architect’s link. I’ve been doing this for a long time, 30+ years, and naming conventions that use Hungarian notation or prefix with underscores just seem old fashioned to me :wink:


#7

Well, they ARE old fashioned. It’s taken me long enough to stop using lots_of_underscores_in_method_and_variable_names (from my early learning days in C) so I figure I can keep my m_ for a good while yet :wink:


#8

Our company went through a phase of putting the scope and type in the variable name:

So I guess it was Hungarian + notation.

(this was from the VB6 days)

miValue = module integer
liValue = local integer
cmiValue = constant module integer

blech … glad that was a quick phase!