Software Principles to Teach Every New Recruit
http://techblog.chegg.com/2015/04/08/software-principles-to-teach-every-new-recruit/
Some coding styles are simply easier to read than others. For example, fewer levels of indentation and brackets is simpler. Less checking of conditions is simpler (and more efficient.)
Coding styles that use less context are easier to follow. Our brains, don’t have huge stacks. Following multiple indentation levels, just like following execution paths through extra code layers, uses up some of our limited capacity. It makes groking the code harder. The code sample on the right terminates execution quickly when it can. The code sample on the left keeps all execution paths lingering all the way to the end of the function. So, at every line later in the function, we have to keep track of what state we’re in at each indent level. That’s not in the spirit of KISS.
http://techblog.chegg.com/2015/04/08/software-principles-to-teach-every-new-recruit/
Some coding styles are simply easier to read than others. For example, fewer levels of indentation and brackets is simpler. Less checking of conditions is simpler (and more efficient.)
Coding styles that use less context are easier to follow. Our brains, don’t have huge stacks. Following multiple indentation levels, just like following execution paths through extra code layers, uses up some of our limited capacity. It makes groking the code harder. The code sample on the right terminates execution quickly when it can. The code sample on the left keeps all execution paths lingering all the way to the end of the function. So, at every line later in the function, we have to keep track of what state we’re in at each indent level. That’s not in the spirit of KISS.