in reply to My first stab at OO perl...
Otherwise, it all looks fine. You've got a lot of the idioms I would use in an OO situation.
A few ideas to bring (and boggle) you further:
That is much easier to maintain when you start hitting 20 or 30 attributes in your objects.sub new { # Stuff up here foreach my $attrib (keys %$self) { my $conv_attrib = $attrib; $conv_attrib =~ s/^_(\w+)$/lc $1/e; no strict 'refs'; *{__PACKAGE__ . "::$conv_attrib"} = gen_closure($attrib); } return $self; } sub gen_closure { my $attrib = shift; return sub { my $self = shift; if (@_) { $self->{$attrib} = shift; } return $self->{$attrib}; } }
Good luck!
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: My first stab at OO perl...
by mp (Deacon) on Jul 16, 2002 at 16:57 UTC | |
by dragonchild (Archbishop) on Jul 16, 2002 at 18:18 UTC | |
Re: Re: My first stab at OO perl...
by Theseus (Pilgrim) on Jul 16, 2002 at 16:00 UTC |