Maintain consistent naming patterns and terminology across the codebase to reduce cognitive load and improve code clarity. The same concept should always use the same name in different contexts.
Maintain consistent naming patterns and terminology across the codebase to reduce cognitive load and improve code clarity. The same concept should always use the same name in different contexts.
Key principles:
on_
for event handlers/callbacks, is_
for boolean predicates, get_
for accessorsstart
/end
for ranges, refresh()
for common update operationsExamples:
-- Good: consistent callback naming
function on_document_highlight(err, result, ctx) end
-- Bad: inconsistent suffix
function document_highlight_cb(err, result, ctx) end
-- Good: consistent terminology
local function get_logical_pos(diagnostic) end
-- Bad: mixing terminology
local function get_logical_location(diagnostic) end
-- Good: established convention
local mark = { start_line = start_row, start_col = start_col }
-- Bad: non-standard naming
local mark = { begin_line = start_row, begin_col = start_col }
When introducing new names, check existing code for established patterns. Consistency trumps personal preference - if the codebase uses a particular naming convention, follow it even if you prefer alternatives.
Enter the URL of a public GitHub repository