CCoding Style - Use else-ifs for multi-way decisions2
Use else-ifs for multi-way decisions ...
- The sequence of ifs requires us to maintain a mental pushdown stack of what tests were made, so that at the appropriate point we can pop them until we determine the corresponding action.
- Align all of the else clauses vertically rather than lining up each else with the corresponding if. Vertical alignment emphasizes that the tests are done in sequence and keeps them from marching off the right side of the page.
- Changing the order in which the decisions are made leads to a clearer version.