
Planning before programming
Often, people start programming before having a general idea of what they want to accomplish. If you're an experienced programmer, this may be a good way to get a feel for the problem, since you have already developed intuition, and you'll probably end up throwing away the first couple of attempts anyway. However, if you're a novice programmer, I recommend you make your objectives clear and explicit before writing any code (putting them into writing can help). It will help you make better decisions by asking yourself how a certain way of doing things will affect your objectives. So, before we set up anything, we need to understand and make our general objectives explicit:
- Understand the big picture of the analysis quickly.
- Reproduce our analysis automatically by executing a single file.
- Save all the resulting objects, text, and images for the analysis.
- Measure the amount of time it takes to perform the full analysis.
- When working on iterative processes, know the completed percentage.
- Be able to find and change each part of the analysis easily.
To fulfill these general objectives, we need to develop modular code with well-managed dependencies that are flexible (easy to change) and friendly to side-effects (saving objects, texts, and images). Even if your explicit objectives don't require it, you should make a habit of programming this way, even when just doing data analysis.