Get Started. It's Free
or sign up with your email address
Function by Mind Map: Function

1. Command query separation

2. Prefer Exceptions to Returning Error Codes

2.1. Extract Try/Catch Blocks

2.1.1. try/catch blocks confuse the structure of the code and mix error processing with normal processing ==> extract bodies of try and catch out into functions.

2.2. The Dependency magnet

2.2.1. should not define error code

2.3. Error Handling is one thing

2.3.1. Functions should do one thing. Error handing is one thing. Thus, a function that handles errors should do nothing else

3. Don't Repeat yourself

4. Structured Programming

4.1. should only be one return statement in a function, no break or continue statements in a loop, and never, ever, any goto statements. But, if function is small -> multiple return, break, or continue statement does no harm and can sometimes even clearly

5. Write function?

5.1. code come out long and complicated has lots of indending and nested loop, arguments, no-good name, duplicate code ==> splitting out functions, changes name, no duplication code, reorder function, break out classes, keep the tests passing.

6. Have no side effects

7. function arguments

7.1. [0,2]

8. use descriptive names

9. switch statements

9.1. always do N things, duplicate code, ... ==> abstract factory

10. one level of abstraction per function

11. Do one thing

11.1. stepdown rule

12. Small