in reply to Re^2: Finding the interface implemented by an object
in thread Finding the interface implemented by an object
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
- The CUMULATIVE(BASE FIRST) approach lacks a degree of control
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".
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.
|
---|