Let\'s say, we have a variable, which we want named Fubar
Let\'s say that Fubar
is a String
!
That means, we would define F
Unluckily there are no common convention, you have to choose what suits most your case, I've seen all the following approaches in different codebases.
Approach 1
private string _fubar; //_camelCase
public string Fubar { ... }
Approach 2
private string fubar; //camelCase
public string Fubar{ ... }
Approach 3
private string _Fubar; //_PascalCase
public string Fubar{ ... }
Also there are frameworks that takes much creativity like using a property and document it as a member variable and thus using member's styling instead of the properties' styling ( yeah Unity! I'm pointing the finger at you and your MonoBehaviour.transform
's property/member)
To disambiguate in our code base we use our homemade rule:
With our approach most times we avoid the doubt about the underscore "_" while at same time having a much more readable code.
private string fubarValue; //different name. Make sense 99% of times
public string Fubar { ... }