Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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.

Replies are listed 'Best First'.
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 :-)

    Enoch was right!
    Enjoy the last years of Rome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821627]
[shmem]: unbelievable success!

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2018-04-20 22:41 GMT
Find Nodes?
    Voting Booth?