Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Beware of object composition!

by merlyn (Sage)
on Feb 05, 2010 at 18:23 UTC ( #821627=note: print w/ replies, xml ) Need Help??


in reply to Beware of object composition!

use Moose; use Your::Delegated::Class; has ydc => is => 'ro', lazy_build => 1, handles => qr/.*/, isa => 'You +r::Delegated::Class'; sub _build_ydc { my $self = shift; return Your::Delegated::Class->new; }
Moose is smart enough to delegate only the things that Your::Delegated::Class knows how to handle, minus the things defined locally. It's like AUTOLOAD delegation, done right. I used this on a recent project when what I wanted was inheritance, but had to use composition and delegation.

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


Comment on Re: Beware of object composition!
Select or Download Code
Re^2: Beware of object composition!
by Jenda (Abbot) on Feb 05, 2010 at 19:12 UTC

    As if I had a chance of having Moose installed sooner than after a year of writing change requests, chasing people several levels up and around to approve them, rewriting them, rerewriting them, getting them rejected by people that write Pearl and think Moose is the animal, resubmitting, ...

    I really should get me a different job.

    Thanks anyway of course :-)

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2014-12-18 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls