[Chicago-talk] Moose Role naming conventions

Sean Blanton sean at blanton.com
Tue Apr 13 06:20:15 PDT 2010


"Blech" it is for now.

Thinking about it a little more, such subtle considerations go into these
decisions.

Animal::Mammal::Dog::Roles::Pet

and

Animal::Mammal::Cat::Roles::Pet

With 25 or so classes in my Eclipse project, let's say I know I need to edit
the Dog Pet role. I have trouble quickly distinguishing between the two
above in the navigator as they both are named Pet.pm in an open folder named
"Role" at the same level. The unsightly naming convention I have helps the
files stick out so I can quickly distinguish Dog_PetRole.pm from
Cat_PetRole.pm. If I get a lot more roles, maybe I'll end up changing it.

I'm using the <role>->meta->apply() form, which is pretty ugly no matter how
you look at it.

It definitely won't show up in a CPAN module, and thanks for the feedback

On Mon, Apr 12, 2010 at 11:24 PM, Elliot Shank <chicago.pm at galumph.com>wrote:

> On 4/12/10 2:38 PM, Sean Blanton wrote:
>
>> Since Moose Roles go into the same package format as regular classes,
>> how are people organizing them so they can be distinguished from classes
>> that use them?
>>
>> A) Through namespace, as in:
>>
> [chop]
>
>  B) through the package names (I think I'm going to go with this one):
>>
>> My::Dog
>>
>> My::Dog_GuideRole
>>
>> My::Dog_StrayRole
>>
>
> $rover->does('My::Dog_StrayRole')?
>
> Blech.
>
>
>  C) or you don’t care at all about the fact that a .pm file might be a
>> Moose role:
>>
>> My::Dog
>>
>> My::Dog::Guide
>>
>> My::Dog::Stray
>>
>
> I'm for this one.
>
> See Stevan Little's own opinion on role naming:
> http://perl.markmail.org/thread/k77octqrujt5w2pb
>
>
>  I’d like to hear what others consider when making a decision.
>>
>> Does a Moose role even have to be a package?
>>
>
> It needs a namespace like anything else does.
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20100413/9b5f5cf5/attachment.html>


More information about the Chicago-talk mailing list