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:
MAX_STATUS_CHARS
instead of MAX_TOOT_CHARS
when “status” is the established term in code)moderation_notes
instead of report_notes
when used across multiple contexts)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.
Enter the URL of a public GitHub repository