·
Reasoning semiformally about correctness is the way to go: use hand checking when automated tools can't.
Check by dividing your code into sections from a single line to a bunch of ten lines.
Choose your section by concept: preconditions, postconditions (for functions), and invariants (for loops and classes).
The sections should be as independent as possible, to facilitate reasoning and modification.
Most of these practices should be adopted:
- Avoid using goto statements
- Avoid using mutable static variables
- Make the variable scope the smallest possible.
- Make when possible your variables immutable
- Indent your code
- Use self-documenting, self-descriptive names
- Extract functional code unit into function
- Make your functions short and one goal-focused (24 lines limit)
- Limit if possible to 4 parameters (group them in an object if necessary --request)
- Your interfaces should be narrow hashtag#encapsulation
- Use setters when necessary
#programmer #reasonable #coder #goodPractices #developer #programming