Concern Naming Conventions
Use consistent naming patterns for concerns that communicate their purpose at a glance.
Why
- Self-documenting: Good names tell you what a model can do or has
- Consistency: Predictable naming makes the codebase easier to navigate
- Discoverability: Developers can guess concern names without searching
Naming Patterns
Adjectives ending in -able (Most Common)
Use for capabilities or behaviors the model can perform:
module Card::Closeable # Can be closed
module Card::Assignable # Can be assigned
module Card::Searchable # Can be searched
module Card::Watchable # Can be watched
module Card::Taggable # Can be tagged
module Card::Postponable # Can be postponed
module User::Mentionable # Can be mentioned
module User::Transferable # Can be transferred
module Board::Accessible # Has access control
module Account::Cancellable # Can be cancelledAdjectives ending in -ed (State/Tracking)
Use for concerns that track or materialize state:
module Storage::Tracked # Tracks storage usage
module Storage::Totaled # Has materialized totalsNouns (Features/Concepts)
Use when the concern represents a distinct feature or concept:
module User::Avatar # Has avatar functionality
module User::Role # Has role/permissions
module Card::Mentions # Has @mentions functionality
module Card::Statuses # Has status management
module Account::Storage # Has storage managementPresent Participles (Actions)
Use sparingly for action-focused concerns:
module User::Filtering # Provides filtering capabilities
module Card::Broadcastable # Handles Turbo broadcastingDerived from Associations
Sometimes name after the association it manages:
module User::Accessor # Manages Access records
module User::Assignee # Acts as an assignee
module Board::Cards # Manages cards relationshipBad: Inconsistent or Unclear Names
module CardHelpers # Too vague
module CardMixin # Meaningless suffix
module DoesCardStuff # Not a proper adjective/noun
module CardClosingBehavior # Overly verbose
module CloseableCard # Wrong order - model name comes first in namespaceGood: Clear, Consistent Names
module Card::Closeable
module Card::Assignable
module Card::Eventable
module User::Notifiable
module Board::AccessibleNaming Decision Tree
- Does it add a capability the model can do? → Use
-able(e.g.,Searchable) - Does it track state or provide data? → Use
-edor noun (e.g.,Tracked,Storage) - Does it represent a distinct feature? → Use noun (e.g.,
Avatar,Role) - Does it manage an association? → Consider deriving from association name
Rules
- Prefer
-ablesuffix for behaviors and capabilities - Use the model namespace prefix (
Card::, notCardprefix) - Keep names short - one word when possible
- Be consistent across the codebase
- Names should be guessable - a developer should be able to find concerns without searching