Difference between revisions of "Best Coding Practices"
From Coder Merlin
Line 8: | Line 8: | ||
** DRY: Do Not Repeat Yourself | ** DRY: Do Not Repeat Yourself | ||
** DIE: Duplication is Evil | ** DIE: Duplication is Evil | ||
** In general, avoid mid-function exits | |||
* Clean loops with clearly defined exits | |||
** In general, avoid mid-loop exits | |||
* Appropriate indentation | * Appropriate indentation | ||
* Helpful whitespace | * Helpful whitespace |
Revision as of 10:31, 11 April 2019
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
- No global variables
- Appropriate capitalization
- Appropriate and descriptive variable names
- nouns are usually most appropriate
- Appropriate and descriptive function names
- verbs are usually most appropriate
- Appropriate use of functions
- DRY: Do Not Repeat Yourself
- DIE: Duplication is Evil
- In general, avoid mid-function exits
- Clean loops with clearly defined exits
- In general, avoid mid-loop exits
- Appropriate indentation
- Helpful whitespace
- Appropriate placement of closing braces and parentheses
- Appropriate use of preconditions
- Deliberate and helpful comments
- Avoid "obvious" comments
- Avoid deep nesting
- Limit line length
- Appropriate file organization
- Generally one class per file