Example: I have a Person class and a Role class. I want to extract the role functionality from both Role and Person into a mixin. I get two mixins: Actable to be included in Role and Adaptable for Person.
I sometimes can't think of a proper english word that fits. In the above example, adaptable seems more fitting for roles than for people, because roles can be adapted and thus are adaptable. A better name would be versatile but that breaks the convention of mixin names with ending in ...able. (It's still an adjective though.)
Other example is when I want to add a module that allows checking, if a Person is allowed to view other persons. How do you find a name for that ending in ...able? Viewable seems impropriate, the person that can be viewed should be viewable. I stuck to showable for now (fitting with the method name in the controller). But then again, it's the Person that can be shown, that should be showable not the person that wants to show.
So I guess my question is, When there is no proper english adjective ending in ...able for a module name, should I choose another adjective that does not end in ...able or should I give it a name that does not quite fit?
By convention, method names begin with a lowercase letter. (Method names can begin with a capital letter, but that makes them look like constants.) When a method name is longer than one word, the usual convention is to separate the words with underscores like_this rather than using mixed case likeThis .
Mixins in Ruby allows modules to access instance methods of another one using include method. Mixins provides a controlled way of adding functionality to classes. The code in the mixin starts to interact with code in the class. In Ruby, a code wrapped up in a module is called mixins that a class can include or extend.
How about a prefix then?
CanDoSomethingMoreComplexThanASingleVerb
edit: While I understand I'm not offering a convention per se (thanks arulmr for bringing it up), the Can Naming convention to describe something is part of de-facto localised naming standards in many companies, as it allows a more verbose description of the functionality you're trying to mixin. e.g. CanAct and CanBeCastInPlay are distinct properties using the original author's context of Person and Role and are easier to percieve and understand than Actable and PlayCastable or other equivalents.
Bottom line: Don't be constrained by language and conventions alone :)
I tend to go verbose and name modules with a longer description of the code they include; something like:
PersonRoleFunctionality
I'll often namespace it too; and file it with other mixins under a directory that applies to the object it was extracted from, so I end up with
include Extracts:Person:RoleFunctionality in the app\models\extracts\person\ directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With