Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Code Maintainability

by TGI (Vicar)
on Dec 04, 2008 at 18:56 UTC ( #728063=note: print w/ replies, xml ) Need Help??


in reply to Re: Code Maintainability
in thread Code Maintainability

I like statement modifiers at the end for simple things like an early return, or throwing an exception. To handle longer lines I use indention:

die 'Detailed error messages are important, especially when this error + happens' if $oops;

But with the long exception you showed I might do:

Exception::Of::Doom->throw( error => 'Detailed error messages are important, especially when t +his error happens', ) if $oops;

I often hear that switching the order is difficult and that it is a good reason not to use the trailing conditional. In practice, I haven't found that switching the conditional around to be that onerous. A good text editor makes it easy. If switching was so hard you would see more of this:

do { turn_green(); throw_up(); die "Ach, food poisoning"; ) if $ptomaine;


TGI says moo


Comment on Re^2: Code Maintainability
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2014-08-31 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls