Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Control Flow - Multiple returns or nested conditionals

by eyepopslikeamosquito (Bishop)
on Oct 07, 2010 at 20:50 UTC ( #864085=note: print w/replies, xml ) Need Help??


in reply to Control Flow - Multiple returns or nested conditionals

I find the first one clearer and easier to understand.

Our coding standards do not mandate "single point of exit"; by all means use it where it makes the code clearer, but enforcing it leads to clumsy, deeply nested code, with extra "flag" variables to keep state. At least that's what I've seen. In any case, with the growing use of exceptions in modern languages, single point of exit is somewhat illusory.

More important than single point of exit is to keep functions cohesive and short, with few parameters, and free of globals.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-08-04 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (43 votes). Check out past polls.

    Notices?