in reply to Re^2: Coding styles using if/else
in thread Coding styles using if/else
Interesting.
I just make sure the conditional as clear as possible, so I'll have if ( SomeCondition) { .. or unless ( SomeCondition ) { ..; then the blocks follow logically after that.
Under your guideline, my code
if ( SomeCondition ) { $this = 'that'; $foo = 'bar; $quux{'quaz'} = [ $this, $that ]; # More code follows .. } else { $this = 'the other'; }
would be rewritten as
if ( !SomeCondition ) { $this = 'the other'; } else { $this = 'that'; $foo = 'bar; $quux{'quaz'} = [ $this, $that ]; # More code follows .. }
I find that harder to read, because I would need to take the condition, reverse it, and then follow what's going on in the first block. For the second block, I'd have to go back to the original, un-reversed condition.
It's just not the way my brain works. ;)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Coding styles using if/else
by jdporter (Paladin) on Apr 06, 2007 at 18:27 UTC |