<?xml version="1.0" encoding="windows-1252"?>
<node id="136115" title="Re: Why I Hate Nested If-Else blocks" created="2002-01-03 21:06:20" updated="2005-07-27 14:36:10">
<type id="11">
note</type>
<author id="85580">
dragonchild</author>
<data>
<field name="doctext">
Bravo! ++.
&lt;p&gt;This sounds very much like a call to think through one's designs first. (You do design, right?) Laying out the branches on paper is a very good way of doing this.
&lt;p&gt;Of course, there are some gotchas. For example, the place I'm at right now has a lot of legacy code that uses the form
&lt;code&gt;
sub foo {
    my $self = shift;

    if (ref $self) {
        # Do stuff
        return $some_useful_value;
    } else {
        # Complain
        return undef;
    }
}
&lt;/code&gt;
This is vs. the (to me) more intuitive
&lt;code&gt;
sub foo {
    my $self = shift;

    unless (ref $self) {
        # Complain
        return undef
    }

    # Do stuff
    return $some_useful_value
}
&lt;/code&gt;
*blinks* I guess I just proved your point, huh? :-)
&lt;p&gt;------&lt;br&gt;&lt;i&gt;We are the carpenters and bricklayers of the Information Age.&lt;/i&gt;&lt;p&gt;Don't go borrowing trouble. For programmers, this means &lt;i&gt;Worry only about what you need to implement.&lt;/i&gt;</field>
<field name="root_node">
136097</field>
<field name="parent_node">
136097</field>
</data>
</node>
