Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm not sure what traits solve (in this case) that mixins would not have solved, unless leaving the class hierarchy unaltered was critical to you. Anyway, I gotta admit, Class::Trait is pretty cool.
    • Well, since you specifically say "in this case", I suspect you already know the differences between traits and mixins. I just never considered using mixins since they're fundamentally broken and don't provide everything that traits do. Even if they weren't broken, I would probably still go with traits for the extra features. Starting with mixins only to switch to traits when I need the goodies means maintenance work down the road.

      • by bshanks (9554) on 2010.01.20 22:36 (#71546)
        i'm unclear on the difference between mixins and traits, could someone explain it to me? i skimmed this paper (Traits: Composable Units of Behavior [] ) and my conclusion was that the difference is that traits differ from mixins in two ways: (1) traits don't allow one to add new state (fields) to a class, (2) in the case of a name collision when you add multiple traits to a class, none of the colliding methods are imported (you must explicitly alias them); whereas with mixins, the mixin to be imported last overrides previously imported methods. are there other differences as well? thanks