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

Re^3: Conceptual Question About Classes and SubClasses

by jethro (Monsignor)
on Aug 20, 2009 at 16:49 UTC ( [id://790139]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Conceptual Question About Classes and SubClasses
in thread Conceptual Question About Classes and SubClasses

I believe the right approach is to have a method in X that validates whatever is to validate in X. If you can make that method generic, so that it would work for A and B too, even better

Any subclasses for which X->validate does everything that is to do are finished now. Any subclass that has to do something more would have their own validate method. That method would then call the validate method of the superclass ($self->SUPER::validate) and if that returns ok, validate the additional stuff of the subclass.

As you can see, you probably need a validate method in A and in B, BUT you don't need to write any code twice.

  • Comment on Re^3: Conceptual Question About Classes and SubClasses

Replies are listed 'Best First'.
Re^4: Conceptual Question About Classes and SubClasses
by ~~David~~ (Hermit) on Aug 20, 2009 at 21:36 UTC
    Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2024-04-18 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found