tima has asked for the wisdom of the Perl Monks concerning the following question:

What is the difference between a Role and Trait? I've read the CPAN docs and even some of the academic papers trying to get my head wrapped around this stuff.

Reason being I'm active in the MTOS (Movable Type Open Source) community and the discussion about "whatever-able" classes comes up occasionally and whose use is growing.

Let me explain what I mean by "whatever-able" classes in how they are used in MT.

It started off as Taggable (object can be tagged), then Scorable (object can be rated or scored) was introduced and now there is discussion of others like comments and categories. The thing is these "whatever-able" classes are designed that your data object must inherit them which usually means multiple inheritance. It also means only the developer of the object class has the option of making an it taggable etc. So if I'm doing some consulting and the client needs a blog object to be taggable and it's not (not yet so far) I'm out of luck or I could trying some nasty hacking that is sure to break later when new versions are released.

After reading about roles and traits it seems one of these approaches is the saner/better way to go especially since modularity and flexibility and extensibility are cornerstones of MT going forward.

Here are some samples classes from MT to give you some code to look at:

So I need a sanity check and thought I'd post something here. Correct me if I'm wrong.

Your feedback would be appreciated. Thanks.