Prompt
Choose names that clearly communicate purpose and align with established domain terminology. Prioritize semantic clarity over brevity, and ensure consistency with the codebase’s vocabulary.
Key principles:
- Use domain-consistent terminology (e.g.,
MAX_STATUS_CHARSinstead ofMAX_TOOT_CHARSwhen “status” is the established term in code) - Name components based on their actual scope and purpose (e.g.,
moderation_notesinstead ofreport_noteswhen used across multiple contexts) - Extract complex logic into descriptively named methods that communicate their intent
- Choose user-appropriate terminology in UI contexts (e.g., “Filtered” instead of technical terms like “NOOP”)
Example of good semantic naming:
# Instead of inline complex logic:
if @report.account.local? && !@statuses.empty? && (@report.account.user.settings['web.expand_content_warnings'] || @report.account.user.settings['web.display_media'] == 'show_all')
# Extract to semantically named method:
if @report.account.local? && !@statuses.empty? && @report.account.user.all_content_visible?
# Method clearly communicates its purpose:
def all_content_visible?
settings['web.expand_content_warnings'] || settings['web.display_media'] == 'show_all'
end
This approach reduces cognitive load, improves code maintainability, and makes the codebase more accessible to new developers.