1 KiB
1 KiB
Coding for humans
- Code is instructions for machines.
BUT
- Code is read by humans.
- Humans need to be able to understand code easily.
- Not all humans think about code the same way
SO
- Write maintainable code
- If design is about usability, coding is about maintainability
- Write boring code that's easily modified and extended
- Consistent patterns
- Avoid obscure and fancy syntax
- Aim for maximum readability
- Use dev tools to make the job easier and less error-prone
- Syntax highlighting
- Code completion
- Linters and formatters
- Static analysis
- Statically typed languages or type hinting
- Write documentation to guide devs
- Explain how programs work so devs don't have to reverse-engineer your team's work.
- Explain the reasoning behind obscure solutions.
- Document pitfalls you've fallen into so other devs don't do the same.
- Write code that accommodates different kinds of devs. Devs can be:
- Inexperienced:
- New to the codebase
- Opinionated
- Impatient
- Bored
- Tired
- Pressured