|
|
|
|
|
by hamdouni
1097 days ago
|
|
Avoid deep nesting by testing error case first and exiting/returning immediately. Instead of : If foo then
bar
Else
baz
Endif
Now I write: If foo then
bar
return
Endif
baz
Exit early makes the code easier to read and understand |
|
I try to make each method/function to have a single entry and a single exit.
Cond, case, pattern maching in function heads, decision tables, and syntactic sugar in some PLs, allow you to flatten the nested code / branchinbg / conditionals.