As a developer, it has been a struggle on how we can standardize our code.
This guideline is a result of our experience from some of our projects. I hope it will help you as much as it helped us.
While going through the code, check the code formatting to improve its readability and ensure that there are no blockers:
- Ensure that code block starting point and ending point are easily identifiable.
- Remove unnecessary empty lines.
- Remove unused variables and excess codes.
- Ensure that proper naming conventions (Pascal, CamelCase, etc.) are being followed.
- The code should fit in the standard 14-inch laptop screen (at least Col 135). There should not be a need to scroll horizontally to view the code. In a 21-inch monitor, other windows (toolbox, properties, etc.) can be opened while modifying the code so, always write your code in a 14-inch monitor view.
Coding best practices
No hard coding, use constants or configuration values.
- Comments — Do not write comments about what you are doing instead, write comments on why you are doing it. Specify any hacks, workaround, and temporary fixes. Additionally, mention pending tasks in your to-dos which can be tracked easily.
- Use framework features wherever possible instead of writing custom code.
- Remember DRY ( Don’t Repeat Yourself) principle: The same code should not be repeated more than twice.
- Avoid the use of attributes such as ID, specific keys, etc., for one specific function or method. Use them for reusability only.
- The naming of a variable should be precisely stating the value or content.
- Naming functions or methods should be describing its use or action. Additionally, summaries should be a must in describing its use. Indicating the parameters and return descriptions.
- Look for a way to simplify things but not degrading the current quality of the code.
- Code blocks should be readable and easy to understand.