November 2013 Archives

Are roles only semantically different from inheritance?

I've been using roles lately and was going to write about them on However I've come into difficulty in explaining how roles are functionally different from inheritance.

I've found that the typical features described about roles in contrast to inheritance are:

  • Avoid complex inheritance hierarchies

  • Better encapsulation and code re-use by focusing on "does" over "is"

  • Enforce polymorphism through "requires"

The difficulty I'm finding is that all of these features can be provided though inheritan…

About sillymoose