Perl: the Markov chain saw | |
PerlMonks |
Re^3: perltidy block indentationby Tux (Canon) |
on Dec 04, 2013 at 16:55 UTC ( [id://1065615]=note: print w/replies, xml ) | Need Help?? |
I'll try
As you can see in this snippet, there are several expressions that control the start of a working day. After the if/elsif/else the real work starts, as it is the same for all situations: it is common code. Or is it? No it is not! When I am ill, the common code is never executed, so there is no reason whatsoever to have an else block: there is no need for an alternative, as there is no intent to run that common code. My stance is that a function or method should be written in a way that the most likely codepath is the easiest to follow with the eye. Exceptions should exit early.
As you can now deduce, the code after the if/else is run for all cases of the decision tree, and hence reflects the thinking logic. Enjoy, Have FUN! H.Merijn
In Section
Seekers of Perl Wisdom
|
|