Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why I Hate Nested If-Else blocks

by dragonchild (Archbishop)
on Jan 04, 2002 at 02:06 UTC ( #136115=note: print w/ replies, xml ) Need Help??


in reply to Why I Hate Nested If-Else blocks

Bravo! ++.

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.

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

sub foo { my $self = shift; if (ref $self) { # Do stuff return $some_useful_value; } else { # Complain return undef; } }
This is vs. the (to me) more intuitive
sub foo { my $self = shift; unless (ref $self) { # Complain return undef } # Do stuff return $some_useful_value }
*blinks* I guess I just proved your point, huh? :-)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


Comment on Re: Why I Hate Nested If-Else blocks
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://136115]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-07-07 01:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls