For standardizing the process of coding conventions across Organization, We have come up with some ideas which will help us to code in same fashion and ofcourse it will be updated based upon the best opinion received about a particular convention.
- Choose easily readable identifier names.
For example, a property named HorizontalAlignment is more English-readable than AlignmentHorizontal and CanScrollHorizontally is better than ScrollableX.
- Don’t use underscores, hyphens, or any other nonalphanumeric characters.
- Don’t use Hungarian notation (Specifying the type with variable name).
For example : strUsername, dtStudents, btnSubmit are not allowed where as Username, Students, Submit are perfectly acceptable
Using Abbreviations and Acronyms
- Don’t use abbreviations or contractions as part of identifier names.
For example, use GetWindow rather than GetWin.
- Acronyms should be discouraged, use only wherever they are unavoidable but acceptable only in case of module.
For example : stName is wrong whereas studentName is right but In case of a module let’s say the module name is PaymentPlanConfiguration then for naming the class use of PCRUsers is allowed
Using singulars and plurals
- Wherever the name represents a single entity then it should be named singular.
Student student = new Student(); //Acceptable
Student singleStudent = new Student(); //Not Acceptable
Student objStudent = new Student(); //Not Acceptable
- Wherever the name represents a collection which can be an array or list then it should be named plural.
Student students = new Student; //Acceptable
Student fiveStudents = new Student; //Not Acceptable
Student multipleStudents = new Student; //Not Acceptable
Microsoft’s General Naming Conventions