Roles are the Perl way to ensure a class adheres to a certain design. In Linux you can OPEN a socket or a file or a device driver or whatever else. They are treated the same because they conform to a certain interface. You might want plug in different sorting algorithms without knowing the details of how they work. A role is just one language's implementation of a concept with the goals of reusing code, minimizing dependency, and designing with flexibility in mind. Sub classes and abstract classes have greater dependency because changing a parent class changes every child class. Often times you'll want to change behavior of a child object, but.. oh wait all that code is in the parent.
HackaMol - OO Perl for molecular hacking PDF explaining design
Add Dry-Run testing to classes
http://blogs.perl.org/users/ovid/2010/01/roles-without-moose.html
In reply to Re: Why Moose roles?
by trippledubs
in thread Why Moose roles?
by porton
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |