Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Are there any guidelines on how to name roles?

Nope, I tend to do a lot of "WithSomething" and "HasSomething", but only when it makes sense. I am really not a fan of the Java/C# interface practice of prepending an "I", so I would not suggest the same but with an "R" unless you like that practice.

I think the "does" comes from the Perl6 keyword. But in Moose the keyword is "with", so that confuses things a bit.

The reason we have "with" is that since that is really just a function, it would conflict with the "does" that is found in Moose::Object which is used to tell if something "does" a role $object->does(My::Role). I would have preferred to have used "does" and be more Perl 6 compat, but I had to work around the Perl 5 limitations.

FWIW, the "with" keyword comes from Scala.

So, any good ideas on how to think or phrase the description of names for classes and roles?

Not yet really, although I haven't given it a whole lot of thought. I am sort of waiting to see, as the group of people using roles grows, what patterns (actual patterns, not GoF patterns) begin to develop for usage and naming. At this point myself and nothingmuch have probably been using roles the longest (at least in Moose) and we each have our own approaches (see Forest and Bread::Board for examples of my usage and KiokuDB and Class::Workflow for examples by nothingmuch).

I guess to not answer your question more clearly,.. there are no rules :)

-stvn

In reply to Re^7: Sanity Check: Roles vs. Traits by stvn
in thread Sanity Check: Roles vs. Traits by tima

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (None)
    As of 2024-04-19 00:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found