I'm still new to the OO thing, so I'm not exactly sure what you are looking for here, but since you have the book, you might want to take another look at the chapter on inheritance. I believe you can inherit the whole kit and kaboodle in some kind of initiatizable class or something. e.g.
And then you'd call it like:package _Initializable; sub new { my ($self,$args); my $private_stuff = "private"; my $class_data = { do stuff here "class_data" => $private_stuff}; bless $class_data, ref($class)||$class; $self->_init($args); # pass them back to the calling mod }
use _Initializable; package Caller; # suck "new" in from _Initializable, along with our # data private to object Caller when we call # $foo=Caller->new($arg) elsewhere @Caller::ISA = qw(_Initializable); # no "new" constructor in any of our stuff... we use _init # to do "construction" # now so that we inherit from _initializable # obviously if you want to provide a class method in # _Initializable for the private data, that wouldn't be too # difficult. sub _init { my ($self,$arg) = @_; do other stuph return $self; }
As I understand it, any method you put in _Initializable (or any other module you inherit, for that matter) is masked if you make a method with the same name as the one in _Initializable. As I say, I'm pretty new to the whole concept of OO, so I may have completely missed the point. As you can see, most of this is a complete crib from Conway's book, chapter 6.
In reply to RE: opinions on the best way to inherit class data
by tenatious
in thread opinions on the best way to inherit class data
by d_i_r_t_y
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |