Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: •Re: It's a dog, but what kind? (polymorphism , in Perl OO)

by rinceWind (Monsignor)
on Mar 24, 2004 at 11:12 UTC ( [id://339444]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to •Re: It's a dog, but what kind? (polymorphism , in Perl OO)
in thread It's a dog, but what kind? (polymorphism , in Perl OO)

As you point out, using a constructor on an existing object is something unnatural; I agree that ref($proto) should be avoided in normal cases.

However, there are times when you specifically want to clone or template a new object (e.g. Class::Classless). I you are doing something like this, you should make it clear in the POD that this method call is available, and precisely what it does. This should state (if this is the case) that new can be use both as a class method call and an object method call.

Also, as part of the POD, it forms part of your interface contract. You should write tests which exercise all the options and prove that your code matches what the POD expects to happen.

My $0.02

--
I'm Not Just Another Perl Hacker

  • Comment on Re: •Re: It's a dog, but what kind? (polymorphism , in Perl OO)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://339444]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.