Basic rule for Naming Convention in C#.
1738
27-Sep-2016
Abhishek Srivasatava
27-Sep-2016Naming Convention :
1: Always try to choose easily readable identifiers names. eg. : Identifier to indicate girl height and boy height, we can use GirlHeight and BoyHeight.
Example:
2. Always use brevity words.
Brevity means concise and exact use of words in writing or speech.
Example:
3. Avoid use of underscores, hyphens or any other non-alphanumeric characters.
Like don't use Girl_Height, Girl1 etc.
Example:
4. Avoid use of Hungarian Notation. It creates contradiction as well as ambiguity to
the developer.
What is Hungarian notation?
Notation which start like intA or charC , stringZ etc. are called Hungarian Notation.
There are some language where there is no datatype for example Basic Combined Programming Language (BCPL) so there is necessary to use this notation.
Example:
language.
Don’t use name as class, exception, string etc.
Example:
6. Do not use abbreviation or contradiction as part of identifiers names.
Example:
7. Class name should be a noun and meaningful, avoid the use of verbs. Don't prefix (“C”) in class name. Always use 1st word as a capital letter.
Example:
8. Namespace: names should be meaningful and complete. Always use 1st word
as capital letter
9: Methods: Always use a verb-noun pair. Avoid use of camel casing.
Camel Casing means that the word which starts with small letter and then capital letter eg: iPhone. there is no use of spaces or hyphen in this format
Example:
10. Private Member Variables: if we are declaring private member variable then we should add prefix or suffix to all class level member variables with (underscore)
eg:. m_ or _m.
Example:
11. Interfaces: It should have prefix 'I' interface.
Example: