A function (method) is a the first line of organisation in any program.
Rules for making the functions communicate their intent:
- not small but very small
- do one thing – can you extract another method from it with a name that is not a restatement?
- use descriptive names
- number of arguments: niladic, monadic, dyadic, triadic (to avoid)
- no side effects, no hidden things, do only what you promised in the name
- do something (change the state of an object )or answer to something (return some information about the object), not both
- use exceptions instead of error codes
- Don’t Repeat Yourself – duplication, the root of all evil.