3 Basic Rules in C

Credits to Mark Davis

  1. Functions should do 1 thing and only 1 thing. The minute a function tries to do 2 or 3 things, or it goes over 50-60 lines (with a few exceptions around conditionals) it is trying to do to much.

  2. Check all parameters for validity before doing anything else in the function.

  3. Check all return values.