S
Scott M.
I am looking at some best practices concerning the naming of identifiers in
C# and am puzzled on what to do with Public and Private identifiers that are
related, such as private fields and their corresponding public properties.
From "Visual C# .NET Step by Step" (pages 29 & 30):
//*********************************************************************
The Microsoft .NET Framework documentation makes several recommendations
about variable naming:
1. Don't use underscores.
2. Don't create identifiers that differ only by case.
3. Use Camel Case.
4. Don't use Hungarian notation.
* You should treat the first two recommendations as compulsory because they
relate to CLS compliance. If you want to write programs that can
interoperate with other languages, such as VB.NET, you need to comply with
these recommendations.
//*********************************************************************
Ok, now I can understand item #2 because VB.NET is not case-sensitive, so it
wouldn't be able to tell the difference between x and X.
But what about underscores? I like to name my private variables with an
underscore and the public property that abstracts the private variable
without so that something other than case can differentiate them, such as:
[VB.NET]
Private _numberEmployees As Short
Public Property NumberEmployees As Short
C# and am puzzled on what to do with Public and Private identifiers that are
related, such as private fields and their corresponding public properties.
From "Visual C# .NET Step by Step" (pages 29 & 30):
//*********************************************************************
The Microsoft .NET Framework documentation makes several recommendations
about variable naming:
1. Don't use underscores.
2. Don't create identifiers that differ only by case.
3. Use Camel Case.
4. Don't use Hungarian notation.
* You should treat the first two recommendations as compulsory because they
relate to CLS compliance. If you want to write programs that can
interoperate with other languages, such as VB.NET, you need to comply with
these recommendations.
//*********************************************************************
Ok, now I can understand item #2 because VB.NET is not case-sensitive, so it
wouldn't be able to tell the difference between x and X.
But what about underscores? I like to name my private variables with an
underscore and the public property that abstracts the private variable
without so that something other than case can differentiate them, such as:
[VB.NET]
Private _numberEmployees As Short
Public Property NumberEmployees As Short