Summary and recommendations
Some simple hints and tips in order to write clean and clear code
- Spell out the algorithm and have a top-down approach to the flow of data
- Start with coding as close as possible to eventual mathematical expressions
- Use meaningful names for variables
- Split tasks in simple functions and modules/classes
- Functions should return as few as possible variables
- Use unit tests and make sure your codes are producing the correct results
- Where possible use symbolic coding to autogenerate code and check results
- Make a proper timing of your algorithms
- Use version control and make your science reproducible
- Use IDEs or smart editors with debugging and analysis tools.
- Automatize your computations interfacing high-level and compiled languages like C++ and Fortran.
- .....