Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Coding styles using if/elseby superfrink (Curate) |
on Apr 06, 2007 at 06:50 UTC ( [id://608613]=note: print w/replies, xml ) | Need Help?? |
I used to work at a company that had a policy of using the first method. ie of leaving off the else. (They did code reviews.) It was claimed that this lead to more "linear" flow rather than deeply nested flow. The idea is that the example if block is checking for (and dealing with) an exceptional situation. That check/deal step is a logical unit with respect to whatever the code it is part of is trying to accomplish. Once that check/deal step is done the program continues on with the next step. Including an else clutters the code and slightly hides the main focus of the code. Another effect of using else where it is not needed is it increases the level of nesting. That often makes code harder to understand. The company also had commenting standards so the code might look something like the following. GOAL means "something we want to do". CLAIM means "something that is true at this point in the code".
In Section
Seekers of Perl Wisdom
|
|