YAPC::Asia 2009

(Parameterized) Roles

By Shawn Moore (‎sartak‎) from Tsukuba.pm
Date: Friday, 11 September 2009 14:20
Duration: 40 minutes
Language: English
Tags: moose moosex parameterized role roles

You can find more information on the speaker's site:

Roles are an excellent object-oriented tool both for allomorphism and for reuse.

Roles facilitate allomorphism by favoring "does this object do X" versus "is this object a subclass of X". You often care more about capability than inheritance. In a sense, roles encode types better than inheritance.

Roles also provide an excellent faculty for reuse. This effectively eliminates multiple inheritance, which is often the only solution for sharing code between unrelated classes.

Roles can combine with conflict detection. This eliminates accidental shadowing of methods that is painful with multiple inheritance and mixins.

Parameterized roles (via MooseX::Role::Parameterized) improve the reusability of roles by letting each consumer cater the role to its needs. This does sacrifice some allomorphism, but there are ways to restore it.

Attended by:


Brought To You By

YAPC Sponsors

  • O'Reilly Japan
  • Contents One
  • Six Apart
  • Booking.com
  • Fractalist
  • 募集中

Media Sponsors (50音順)

  • @IT
  • O'Reilly Japan
  • gihyo.jp
  • Shoeisha
  • 募集中

JPA Platinum Sponsors

  • S2 Factory
  • endeworks
  • GaiaX
  • DeNA
  • mixi
  • livedoor

JPA Gold Sponsors

JPA Silver Sponsors

  • Adjust
  • Intfloat
  • KDDI Web Communications
  • Seesaa Co. Inc.
  • Six Apart
  • Paperboy & co
  • Plugin and Core
  • Mobile Factory

JPA Bronze Sponsors

  • Soffritto
  • wadit