Programming languages have varying syntax requirements, but generally allow for many styles, like tabs vs spaces. Using a style guide helps create consistency and is based on the language. IDEs can help by autoformatting code.
You read code more than you write it.
Style Guide Specifics
Some of the conventions listed in style guides are
- Number of characters for indentation
- Max characters on line
- Use of whitespace in expressions
- When to use comment types
- Variable name and format usage
- Use of trailing commas
Regardless of the style, consistency is most important.
Code Habits
- Everything is commented
- Comments outweigh code extremely
- Long names
- Long parameter lists
- Duplicated code
- Inconsistent naming
- Very long files
Too much nesting
Code really shouldn’t go beyond 2-3 levels deep, otherwise it becomes difficult to read and reason.
Ambiguous Variables
Variables should be readable and understandable, describing their content.
Complex Functions
The longer a function is, the less readable and maintainable, and should be divided into smaller components.