uuid: - value: 8108dc36-1eb3-487b-9c03-600c49a6d11c langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-05-11T09:00:18+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: 'Conventions over readability?' created: - value: '2024-03-08T00:00:00+00:00' changed: - value: '2025-05-11T09:00:18+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2024/03/08/conventions-over-readability langcode: en body: - value: |
I previously wrote about why you shouldn't use variable names like $x
and $y
in your code and why you should use more descriptive names.
But what if there is an existing convention?
For example, I use Lua to configure Neovim and noticed that it's common to use shortened variable names, such as buffer
instead of buffer_number
or bufferNumber
.
It's also common to use the variable M
to declare a module. For example:
local M = {}
M.find_files = function()
// ...
end
return M
Whilst Module
would be a more descriptive name, would deviating from the convention be more confusing for anyone reading the code?
Do the benefits of following a convention outweigh the benefits of using more descriptive variable and function names?
Which would be easier for newcomers to your project or team to understand and allow them to be productive sooner?
format: full_html processed: |I previously wrote about why you shouldn't use variable names like $x
and $y
in your code and why you should use more descriptive names.
But what if there is an existing convention?
For example, I use Lua to configure Neovim and noticed that it's common to use shortened variable names, such as buffer
instead of buffer_number
or bufferNumber
.
It's also common to use the variable M
to declare a module. For example:
local M = {}
M.find_files = function()
// ...
end
return M
Whilst Module
would be a more descriptive name, would deviating from the convention be more confusing for anyone reading the code?
Do the benefits of following a convention outweigh the benefits of using more descriptive variable and function names?
Which would be easier for newcomers to your project or team to understand and allow them to be productive sooner?
summary: null field_daily_email_cta: { }