“The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that”
- a function should only do one thing: A function that only does steps that are one level below the stated nane of the function, then the function is doing one thing.
- Avoid switch statements. If you need them abstract them away using an ABSTRACT FACTORY PATTERN
- a function should have a max indent of 2
- a function should only have one or two arguments. Three arguments need special justification. Four arguments is not done.
- a function should not have side effects. It should not do anything that isn’t implied by its name.
- a fuction should either do something or answer something (get something). Functions that change state should not return values and functions that return values should not return state.
- Use Exceptions above error codes