Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Control Flow - Multiple returns or nested conditionals

by RecursionBane (Sexton)
on Oct 08, 2010 at 20:21 UTC ( #864276=note: print w/ replies, xml ) Need Help??


in reply to Control Flow - Multiple returns or nested conditionals

Thanks for creating this node. I've often wondered if what I'm doing is the right thing. I tend to flip-flop between both methods based on the following criteria:

* If the routine has flow modifiers like goto or next, I use a single return statement.

* If the routine has no flow modifiers and has code duplication that aids readability, I use multiple return statements to keep each duplicated section independent (they can now be jettisoned on-demand).

* If the routine has flow modifiers and code duplication, I use multiple return statements with a debug print statement before every return (during development). I also suddenly turn religious and start praying.

Writing mostly baby Perl (see "Baby" Perl versus "Bad" Perl), though, means I don't really adhere to "coding standards".

~RecursionBane


Comment on Re: Control Flow - Multiple returns or nested conditionals

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2015-07-04 11:11 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 (59 votes), past polls