Short answer:
Prefix members and parameters with m_ "and" p_ "or" s_ "if the element is static.
Do not decorate properties or locals , and when you feel that you should call them the same (ignoring the case), resolve the conflict by prefixing the properties with "this". "
Explanation:
Consider that there are at least four (4) different categories of readable / assigned names that must be different: Local variables , Variable members (instance and static), Properties, and Parameters method. All four categories can be displayed in one block of code, so each of them needs clear distinctive characteristics.
A meaningful prefix can simultaneously distinguish between variables and reveal their scope, such as m_ (member), s_ (static), p_ (parameter), leaving public properties and local variables simple without prefixes and without worrying about case sensitivity. If for some reason you must specify a local object in the same way as a property, regardless of the case, then simply attach the "this" property.
Naming conflicts between Local variables and Parameters does not occur because they cannot be called the same (the compiler will catch a duplicate definition). The same applies to member variables and Properties . Parameters and members with the prefixes "p_" and "m_", respectively, will not conflict, and conflicts between unreadable locales and properties can be resolved by adding "this". to properties.
The alternatives to my suggestions are not very good: case-sensitive (a bad idea, because not all CLR languages ​​are case-sensitive), use underscores on their own (also bad because it might run into standards and the damn thing doesn't tell you) or use different names (can be time-consuming, complex and seemingly arbitrary).
Triynko
source share