oliverdavies.uk/content/node.8108dc36-1eb3-487b-9c03-600c49a6d11c.yml

88 lines
3.1 KiB
YAML

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: |
<p>I previously wrote about why you shouldn't use variable names like <code>$x</code> and <code>$y</code> in your code and why you should use more descriptive names.</p>
<p>But what if there is an existing convention?</p>
<p>For example, I use Lua to configure Neovim and noticed that it's common to use shortened variable names, such as <code>buffer</code> instead of <code>buffer_number</code> or <code>bufferNumber</code>.</p>
<p>It's also common to use the variable <code>M</code> to declare a module. For example:</p>
<pre><code class="language-lua">local M = {}
M.find_files = function()
// ...
end
return M
</code></pre>
<p>Whilst <code>Module</code> would be a more descriptive name, would deviating from the convention be more confusing for anyone reading the code?</p>
<p>Do the benefits of following a convention outweigh the benefits of using more descriptive variable and function names?</p>
<p>Which would be easier for newcomers to your project or team to understand and allow them to be productive sooner?</p>
format: full_html
processed: |
<p>I previously wrote about why you shouldn't use variable names like <code>$x</code> and <code>$y</code> in your code and why you should use more descriptive names.</p>
<p>But what if there is an existing convention?</p>
<p>For example, I use Lua to configure Neovim and noticed that it's common to use shortened variable names, such as <code>buffer</code> instead of <code>buffer_number</code> or <code>bufferNumber</code>.</p>
<p>It's also common to use the variable <code>M</code> to declare a module. For example:</p>
<pre><code class="language-lua">local M = {}
M.find_files = function()
// ...
end
return M
</code></pre>
<p>Whilst <code>Module</code> would be a more descriptive name, would deviating from the convention be more confusing for anyone reading the code?</p>
<p>Do the benefits of following a convention outweigh the benefits of using more descriptive variable and function names?</p>
<p>Which would be easier for newcomers to your project or team to understand and allow them to be productive sooner?</p>
summary: null
field_daily_email_cta: { }