package Foo; use BaseClass; our @ISA = qw(BaseClass); attrs qw( foo bar baz ); sub init { my $self = shift; my %options = @_; # Do some stuff here return $self->SUPER::init(%options); } sub foo { my $self = shift; # Do some validation here return $self->_foo(@_); }
It handles diamond inheritance, on-the-fly methods, and provides a simple (but not obtrusive) separation of interface and implementation. Also, you can't mispell a method name and have it DTWT silently, as with direct access to hashes can.
I've never uploaded it to CPAN because there are a plethora of class classes out there. I also never really cared to learn Class::Struct, Class::MethodMaker, and the like, because this does what I need it to do, and nothing more. *shrugs* I probably should, at some point, if only to get into the mainstream.
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
In reply to Re: How do YOU do OO in Perl?
by dragonchild
in thread How do YOU do OO in Perl?
by batkins
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |