General
-
intention vs implementation. Always separate the intention of the fragment of code from its implementation
-
naming. Coming up to good names is hard. A good way is creating a comment describing the purpose of the variable / function / class and create the name from that comment.
-
remove dead code: it makes the code more difficult to understand
-
re-refactor. During a refactor, we can notice that we can reorient the behaviour or the way to code the program.
functions
-
extract function: extract a fragment of code into a function based on length and reusability. If you need to spend time figuring out "what" a fragment of code does, you need a function named "what" with that fragment of code.
-
inline function: if the intention of a function is clear, code is self-explanatory and really short, get rid of the function and mode fragment of code to the original function call.
-
move statements into function: if a statement is more convenient to be inside an existing function, move it inside it
-
move statements into callers: if a statement is more convenient to be outside an existing function, move it outside the function. One trigger for this is when common behaviour used in several places needs to vary in some of its callers.
The rest of the content (15 read minutes) is restricted.
Please use your personal access token or register to access.