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

(Re)+: A few Perl OOP questions. (disparaging)

by rir (Vicar)
on Oct 24, 2003 at 18:17 UTC ( #301916=note: print w/ replies, xml ) Need Help??


in reply to Re^2: A few Perl OOP questions. (disparaging)
in thread A few Perl OOP questions.

I dislike the idiom because it promotes ambiguous code. The author of  $obj->new(); hides something that the author of  (ref $obj)->new(); tells you.

Often it makes no real difference and the noise is about who is being forced to write code to accomodate someone else. I try to be more cooperative.

Usually I would write your new more like this.

sub new { my $class = shift( @_); croak "Bad class parameter" if not defined $class or ref $class; bless [@_], $class; }
Which gives a message like:

Bad class parameter at file.pl line 100

What is it that you find fine about the idiom?


Comment on (Re)+: A few Perl OOP questions. (disparaging)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-08-01 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls