develooper Front page | perl.moose | Postings from August 2016

Re: Why to use Moose roles ever?

Thread Previous
From:
Jed Lund
Date:
August 10, 2016 14:44
Subject:
Re: Why to use Moose roles ever?
Message ID:
CAM4-=+OUh_NfrC9x4oN2SNdbc72VGfgwxTrLfevf-M3di33Lmw@mail.gmail.com
Victor,

My experience has always been that Moose is as flexible as possible without
causing fundamental logical conflicts (And their companion hard to debug
issues).  It is important to note that a Moose Role is not a one for one
match to other programming languages implementations for a role.


https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Roles.pod#Roles-Versus-Abstract-Base-Classes

The question you are asking also falls in the line of a bigger question
that is partially outside of the scope of Moose implementation.


http://www.javaworld.com/article/2076814/core-java/inheritance-versus-composition--which-one-should-you-choose-.html

   https://en.wikipedia.org/wiki/Composition_over_inheritance

Are you aware of the following two pieces of Moose documentation?  The may
help to resolve some specifics around any specific implementations.


https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Roles.pod#METHOD-CONFLICTS


https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Roles.pod#METHOD-EXCLUSION-AND-ALIASING

Best Regards,

Jed

On Wed, Aug 10, 2016 at 6:00 AM, Victor Porton <porton@narod.ru> wrote:

> Moose roles have some limitations, such as inability to override a
> method in a class which "with"es the role.
>
> But I can use an abstract base class instead of a role.
>
> Are there any real situations where roles are better than base classes?
> With examples, please.
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About