Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If one isn't too keen of inheritance and one is not afraid to add dependencies to ones script / module, there also is Class::Delegation, that faciliates containment relationshipts by autocreating the methods that your class delegates to one of its contained elements. For a nice example, see CGI::Wiki, which delegates calls to the database backend via this module. A reason not to use Class::Delegation is, that it does not work below Perl 5.005 - and my ISP has a borked Perl 5.4.3 (Solaris/gcc), which knows nothing of INIT blocks. If someone knows a nice and transparent way to work around the INIT {} block (or rather, how to have Perl 5.004 not throw a syntax error and to have the module still work / compile under Perl 5.4 and 5.5+ as expected), this would be nice :-) - I've thought about some version dependant eval()s, but haven't come to a conclusion. Other than this one-paragraph nit, Class::Delegation helps you avoiding mechanical code that maps method names between your class and the contained object.
In reply to Re: Class::Interface -- isa() Considered Harmful
by Corion
|
|