in reply to bloated 'if' formatting

I have settled on reducing horizontal indentation (code creeping across the screen) by using more vertical indentation.
if ( condition1 or condition2 or condition3 ) { # do something } elsif ( condition4 or condition5 ) { # do something else }
I like the top down feel this approach gives me.

As has been mentioned already, if the code does start creeping across more than, say, 3 'levels of indentation' it almost certainly means it'd be better off being rewritten. I can't hold that many levels of a process/sub processes in my head at a time.

I often take a similar approach to functions/objects. An extreme example:

open( my $fh, '<', 'text.txt', ) or die "died";
Down is better than across :-)

 

Replies are listed 'Best First'.
Re^2: bloated 'if' formatting
by Perl Mouse (Chaplain) on Oct 06, 2005 at 09:56 UTC
    The beauty of an if statement is that if you write if (condition), the condition starts 4 columns further to the right of the start of the if. Which, given a 4-character indent (quite common, and that's what I use) is exactly the same as indenting one level.... (well, at least for me).
    Perl --((8:>*