yaneurabeya has asked for the wisdom of the Perl Monks concerning the following question:
Ok, so I have a class that I'm having a hard time designing properly with inheritance, and I feel confused dealing only with inheritance in OOP in other languages (C++, Java). My only resource isn't much help unfortunately, so I definitely need some Perl-y wisdom from some knowledgeable people right now.
My use model is to have a base class, develop multiple derived classes, piece together the final product as the sum of all of the inherited derived classes, then validate the sum in the final stage prior to executing it. This is being done to reduce maintenance on 30~75+ derived class modules.
So far my class looks something like the following:
#================= # Main require model::MAKE_BASIS; #================= # The following can live in model/MAKE_BASIS.pm package model::MAKE_BASIS; our @ISA= ( qw(Master_Classes::Make pm::Section), @ISA); use Data::Dumper; use pm::Section; $RULES = inheir_merge( exports => { # Environment variables to export at program's runtime. }, opts => { # A hash of options that get passed into a program. }, # Time limit for execution timeout => 12 ); #================= # The following lives in pm/Section.pm package pm::Section; use Data::Dumper; use qw(Exporter); our @ISA = qw(Exporter); our @EXPORT = qw(import inheir_merge); our @EXPORT_OK = qw(import inheir_merge); sub new { my $this = shift; my $class = ref($this) || $this; my $self = { # Empty definition just for example }; bless $self, $class; $self->validate(); } sub import { __PACKAGE__->export_to_level(1, qw(inheir_merge initialize)); } sub inheir_merge { my $class = ref(caller()) || caller(); my $self = {}; bless $self, $class; $self->SUPER::inheir_merge(@_) if($self->SUPER ne __PACKAGE__ +); }
However, when I try and run this piece of code I come up with a message stating:
"Undefined subroutine &model::MAKE_BASIS::inheir_merge"
I'm not sure why this is occurring though because I used use Exporter and all the symbols are being exported properly AFAIK.
Could anyone try and provide a suggestion to either redesign my class or approach the problem that could solve this particular issue?
I greatly appreciate your help.
-Garrett
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dealing with design -- inheritance + exporting gone bad :(..
by Joost (Canon) on Jun 19, 2007 at 22:39 UTC | |
by yaneurabeya (Novice) on Jun 19, 2007 at 23:07 UTC | |
by Joost (Canon) on Jun 19, 2007 at 23:28 UTC | |
by yaneurabeya (Novice) on Jun 19, 2007 at 23:49 UTC | |
by Joost (Canon) on Jun 19, 2007 at 23:55 UTC | |
|
Re: Dealing with design -- inheritance + exporting gone bad :(..
by shmem (Chancellor) on Jun 20, 2007 at 03:11 UTC | |
by yaneurabeya (Novice) on Jun 20, 2007 at 19:44 UTC |