I like case sensative. We use lowercase to denote private variables and
uppercase to denote public ones. Makes it a lot easier to keep track of
things without having to modify the names themselves.
As a general convention it’s not a bad idea as long as the public variable is name slightly differently to the correpsonding private one
However, code like the below is a horrible habit that deserves to go down the waste bin of history
//this sucks
private string name; // the name field
public string Name // the Name property
get{
return name;
}
It can lead to the wrong variable being referenced within a class which will be totally undetectable by the compiler, and easy for a human to miss because the words are so similar.
It is also confusing to anyone learning the language for the first time to see such examples. Things which are different should jump out at the user as being different.
I remember the confusion I felt learning java when the examples were just “hello world” ones with the program name, method and filename all being called “HelloWorld” endless sub main, files called main etc - conceptually different things all called the same name. Oddly enough, when I wrote a more complex program that did different tasks it suddenly became a lot easier to understand.
What’s wrong with a naming convention which relates concepts clearly but does not duplicate them? See below.
//this is a lot clearer
private string nameM; // the name field, M for member
public string Name // the Name property
get{
return nameM;
}
Aside from aesthetics (some might prefer NameM, name_m or even name_) it’s pretty obvious which public properties go with which variables, and it’s glaringly obvious which of the two you’re using!
I like suffixes rather than prefixes because these keep the two together in the intellisense (I understand the dislike of Hungarian mName variables for that reason)
The argument the other way is rather like arguing that it’s better climbing without a safety rope as you should always be able to put your foot in the right place every time! People make mistakes, we set up systems to prevent them and highlight them.