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

Re: Re: OO Inheritence

by exussum0 (Vicar)
on May 25, 2004 at 23:15 UTC ( [id://356409]=note: print w/replies, xml ) Need Help??


in reply to Re: OO Inheritence
in thread OO Inheritence

Croaking in your constructor is a bit harsh. How about undef? As chromatic said, if you dont' read documentation about something, like this, you get what you deserve. I don't agree with that, because if someone carelessly creates something great that ignores croak, and then you use that, you may find yourself with a bug 'cause of some odd situation.

At least w/ undef, you can be more forgiving.

Replies are listed 'Best First'.
Re: Re: Re: OO Inheritence
by stvn (Monsignor) on May 26, 2004 at 00:15 UTC
    At least w/ undef, you can be more forgiving.

    But it also requires that it be checked for. I think returning undef has its place, but so does throwing an exception (a.k.a. - croaking). I see the logic in allowing the user of your object/class/module to choose to die or not, after all, this...

    my $o = Class->new(@arg) || die "cannot create new Class";
    is a common enough idiom. But I can also see the logic in throwing an exception and just requiring the user to catch that exception. For me, it really comes down to how you plan to structure the error handling in the rest of your code.

    -stvn
Re: Re: Re: OO Inheritence
by tilly (Archbishop) on May 27, 2004 at 15:07 UTC
    And you never mistype a parameter name?

    When I've done something wrong, I like informative error messages. Think of error checks like that as being kind of like strict.pm in effect. It saves me time in development. That someone who shoots themselves in the foot deliberately won't see the benefit is not a problem for me.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-25 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found