Last month I wrote about using Moose's override
function to, well, override a superclass's method. Chris Prather on the #moose IRC channel suggested soon after that the around
method modifier (or its little sisters before
and after
) might be a better choice if you're also calling the original method inside. He noted that "at a minimum override
only works if you're subclassing, around
will apply to composing methods too."
His point was that when you decide to compose roles (also know as traits) instead of or in addition to more traditional inheritance, override
simply doesn't work: only a method modifier will do. (And as Graham Knop and Karen Etheridge later remarked on IRC, override
isn't even an option if you're using Moo as an alternative to Moose.)
from DZone.com Feed https://ift.tt/2V0J3vS
No comments:
Post a Comment