Choose a simple set of rules and consistently apply those rules. Automated tools exist to help do that for you.
Files shouldn't be too long (around a max of 200/300 lines)
Code should be ordered from most abstract/general to most detailed from top to bottom
Different complete thoughts/expressions should be separated by a blank line
Lines of code that are tightly related should appear vertically dense; e.g., not separated too far by useless comments
Concepts that are closely related should be kept vertically close to each other. You shouldn't have to hunt to find where things used by other things are in the same file.
If one function calls another, they should be vertically close. The caller should be above the callee if possible.
Variables should be declared as close to their usage as possible. For our goal of very short functions, they should be able to be declared at the top of the function
Lines should have a max of around 80-120 characters
If you are tempted to align a group of declarations and assignments horizontally on each line, it may instead be a sign that they need to be split up. The problem is the length of the list, not the lack of alignment
Ignoring indentation for short if statements/functions/loops is generally bad
bj 2019-09-22