Roles are reusable
- Interchangeable machined parts ...
package Person;
use Moose;
with 'Comparable', 'Printable';
has 'first_name' => (is => 'rw', isa => 'Str');
has 'last_name' => (is => 'rw', isa => 'Str');
sub to_string {
my $self = shift;
$self->last_name . ', ' . $self->first_name;
}
sub compare {
my ($self, $other) = @_;
$self->to_string cmp $other->to_string;
}