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

Re: Re: inheritance turns back and bites

by esskar (Deacon)
on Mar 01, 2004 at 13:46 UTC ( #332894=note: print w/ replies, xml ) Need Help??

in reply to Re: inheritance turns back and bites
in thread inheritance turns back and bites

Always use SUPER instead of the parent-class-name; so in the case of changeing the parent-class, you won't have to replace all the "SomeData::" stuff to the new parent-class-name.
SUPER is pretty super.

Comment on Re: Re: inheritance turns back and bites
Replies are listed 'Best First'.
Re: Re: Re: inheritance turns back and bites
by borisz (Canon) on Mar 01, 2004 at 13:59 UTC
    But SUPER is wrong here, I like to use SomeData or build something with __PACKAGE__.
      If your intent is to ensure that increment calls add in the same package, why not use:
      sub increment { my $self = shift; &add($self, number => 1); }
      Use subroutine calls when you want to create your own explicit binding, use -> notation when you desire runtime binding of the message.

      Of course, it would be my opinion that it is particularly bad form for a child class to re-implement a method in a manner that is not backward compatible - it's a violation of the contract as far as I'm concerned.

      --Toby Ovod-Everett

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2015-11-29 13:22 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (750 votes), past polls