3 ms·
Completely agree on limiting yourself reducing the nesting of code. There is more difficulty working with code such as if x { //... } else { //... } Than cod
by DeliriousDog 2y ago
Completely agree on limiting yourself reducing the nesting of code.
There is more difficulty working with code such as
if x {
//...
} else {
//...
}
Than code like
if x {
// returns from this block
}
// execution continues
In some legacy code I sometimes encounter very long chains of checks which nest 4-8 layers, which becomes very difficult to maintain a mental model of where you are in execution at any point. I try to refactor into the second pattern from above when possible.