Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: (jeffa) 3Re: My first stab at OO perl...

by Theseus (Pilgrim)
on Jul 16, 2002 at 19:52 UTC ( [id://182221]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: (jeffa) 3Re: My first stab at OO perl...
in thread My first stab at OO perl...

That is indeed an option, but I'm of the school of thought that it's better for a program or operation in a program to silently catch an error and correct it for the user than to just fail outright.
  • Comment on Re: Re: Re: (jeffa) 3Re: My first stab at OO perl...

Replies are listed 'Best First'.
Re: Re: Re: Re: (jeffa) 3Re: My first stab at OO perl...
by thor (Priest) on Jul 17, 2002 at 04:46 UTC
    That is indeed an option, but I'm of the school of thought that it's better for a program or operation in a program to silently catch an error and correct it for the user than to just fail outright.

    ...and I'm of the school of thought that a program should silently toil away doing it's appointed task until it encounters something it's not expecting, at which point, it should be noisy as hell. Fixing something for the end user is not always the best solution, because what if your notion of "fixed" is different than what the user had in mind? The road to crufty code becomes short indeed.

    On the other hand, if you want to subsribe to the "be liberal in what you accept and strict in what you output" philosophy (which is what I think you were getting at), that's fine, just don't do it silently. Document every feature that you have coded (as well as known limitations, bugs, etc...)

    thor

Re7: My first stab at OO perl...
by dragonchild (Archbishop) on Jul 16, 2002 at 20:38 UTC
    Catch the error and return an error code, you mean. Don't make up for the failings of your user. Teach him/her the correct way to do things.

    ------
    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.

Re: Re: Re: Re: (jeffa) 3Re: My first stab at OO perl...
by arturo (Vicar) on Jul 17, 2002 at 13:41 UTC

    But this assumes that your code can know what the user^W programmer (inserted later ... sorry) really wanted, which is a dangerous assumption. Why would I call new on an instance in the first place? Maybe it's a typo (I wanted the net method perhaps)? Maybe I really don't grok OO? Silently catching errors that arise at runtime through erroneous user input or network hiccups, etc. is one thing, silently catching a programmer's conceptual or didn't-read-the -API mistakes and correcting them is quite another.

    It is your code though. But if you're ever going to distribute OO modules, I think it would be wise to warn (warn =) the user à la "new called on instance, a copy was created (did you mean to use clone) ?"

    I mistrust all systematizers and avoid them. The will to a system shows a lack of integrity -- F. Nietzsche

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found