There are two important things to note about the Moose solution, which make it superior to the Class::Std solution.
- A Mouse is not a Danger
Inheritance is an "is-a" relationship, and the Class::Std version incorrectly models the Mouse's relationship with Danger. The Moose version states that a Mouse "does" Danger, which still doesn't read quite right, but Danger is clearly more of a Trait of this particular Mouse, and not something that the Mouse "is".
- The CUMULATIVE(BASE FIRST) approach lacks a degree of control
Because CUMULATIVE(BASE FIRST) determines the order in which your methods are called, you are limited to how much control you can have. Using the Moose modifiers before/after/around you have a great degree of control over when and how your methods get called. Moose also provides augment/inner which only works with classes (it makes no sense for roles), but also provides a more flexible and powerful means of controlling dispatch. See the Moose::Cookbook::Recipe7 for a good example of this.
It should also be noted (with all due respect to TheDamian
) that that Class::Std
has 56 outstanding Bugs
some over 2 years old and many which are quite serious. It also seems to be no longer maintained (last upload was Feb. 2006). In contrast, Moose
is very actively developed by a handful of developers and is being used heavily in several large production sites so bugs tend to get fixed rather quickly.