A. General Coding Notes
- Write a few lines as possible.
- Try to have small atomic functions, then avoid long functions
- Use appropriate naming conventions
- Segment blocks of code in the same section into paragraphs.
- Use indentation to mark the beginning and end of control structures. Clearly specify the code between them.
- Don’t use lengthy functions. Ideally, a single function should carry out a single task.
- Use the DRY (Don’t Repeat Yourself) principle. Automate repetitive tasks whenever necessary. The same piece of code should not be repeated in the script.
- Avoid Deep Nesting. Too many nesting levels make code harder to read and follow.
- Capitalize SQL special words and function names to distinguish them from table and column names.
- Avoid long lines. It is easier for humans to read blocks of lines that are horizontally short and vertically long.
- Preferences for creating functions/classes/modules in separate files (rather than one script of 1M lines).
- Any script/code taken from anywhere should be accompanied by a reference/link/license...
- Code Refactoring
- Use Meaningful Names for Variables and Functions
- Provide clear documentation
- Commenting when necessary, as usually, your code should be cristal clear to understand
- Comments explain the "why," not the "how."
- Avoid Obvious Comments, Commenting your code is fantastic; however, it can be overdone or just be plain redundant
- Keep in mind that comments are more about coding clarification, and documentation is more about explanation, role, and theory