Naming and Styling Rules
When you are engaged in programming or get a job in this field after graduation, it is not possible to just freely write program and you have to follow some naming and styling rules that optimize for readability using names that would be clear even to people on a different team. Because each company has different naming and styling rules, so I will cover simple rules for naming and styling rules in this article.
Naming
-
Use names clearly conveying the meaning and use camel casing
-
Class Name: noun for the concept to be presented by the class
Captalized the first letter of each word.
e.g class MyClass -
Variable Name: Name of the contents should be stored
- Start with lower case and all the letter are lowercase with underscore between words.
e.g number_of_students - Function Names: Verb for the method action
- Name of the functions should start with a capital letter for each new word.
e.g CountFooErrors()
Comments
Comments are absolutely vital to keeping our code readable. Although comments are very important, the best code is self-documenting. Thus, giving sensible names to types and variables is much better than using obscure names that you must then explain through comments.