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

Re (tilly) 5: out of loop

by tilly (Archbishop)
on Mar 31, 2001 at 22:58 UTC ( [id://68691]=note: print w/replies, xml ) Need Help??


in reply to Re: Re (tilly) 3: out of loop
in thread out of loop

Couldn't you have just included an example snippet of what it would have looked like and then just included a note that the object you called here is a home-built error-reporting mechanism?

I find that people learn style from what are meant as off-hand snippets, and so I think it is important that everything from pseudo-code on up always at least acknowledge the importance of testing for and dealing with errors. I would prefer that people think, Geez, that tilly is anal about error checking! than accidentally encourage (if only by omission) people to neglect it...

Replies are listed 'Best First'.
Re: Re (tilly) 5: out of loop
by indigo (Scribe) on Mar 31, 2001 at 23:30 UTC
    I probably could have, but I don't think it would have added value. When I write example code, I add detail where it is relevant to the thread, and remove it where it is not. How many times do you see a simple open FILE, "file" or die; in an snippet? To me, it is clear that is just a placeholder, showing, but not elaborating upon, the error handling one would normally expect.

    In fact, my code started out with open FILE, $_ or die; and warn "Error!" if $@;. Perhaps I should have left it that way, making it clear the error handling was in fact a simplification, and not representative of what belongs in a real program.
      How many times have I seen production code with open FILE, "file" or die;? Far too often to give the benefit of the doubt to anyone who writes that in a snippet!

      It doesn't take very many painful midnights debugging what should be straightforward problems to develop that attitude...(The mistakes were made before I arrived there.)

        With the code I have to maintain, I am overjoyed to see open FILE, "file" or die;. Most of the time it is just open FILE "file";.

        Error handling is not a one size fits all proposition. You scale it with the size and importance of your program, and severity and likelihood of the error. If I am writing a one timer, I might not check return values at all; other times, I am going to be as paranoid as possible, checking and double checking everything I can. It is a matter of using the correct amount of error handling for your situation, instead of applying it with a trowel to get as much in there as you can.

        As for burning the midnight oil, I have had to wade through hard to maintain, overly elaborate, and downright buggy error handling schemes at odd hours, where a simple or die; would have told me what I needed to know immediately. The developer responsible refused to acknowledge there was such a thing as too much error handling, or that its complexity made his code less reliable, not more.

        We shouldn't be advocating error handling for error handling's sake alone. It is a judgement to be made based on a number of program specific factors. As for code without context, like the snippets offered here, determinations about the "correct" level of error handling can only be made on the coarsest of levels.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-25 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found