oliverdavies.uk/content/node.df628b2c-64d0-4b35-bbde-c3536bcb05bc.yml

97 lines
3.8 KiB
YAML

uuid:
- value: df628b2c-64d0-4b35-bbde-c3536bcb05bc
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:30+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: |
Only comment what needs to be commented
created:
- value: '2023-10-02T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:30+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2023/10/02/only-comment-what-needs-to-be-commented
langcode: en
body:
- value: |
<p>"If you comment everything, people won't read them."</p>
<p>"As soon as one comment is incorrect, the result will be ignored."</p>
<p>These are two comments I heard recently referring to code comments.</p>
<p>If there are too many comments, people will get lost in the information. They won't be able to differentiate boilerplate comments from valuable ones, and as soon as one comment is incorrect, people will assume that others could likely be incorrect too and ignore them.</p>
<p>A solution to these is to only comment what needs to be commented.</p>
<p>Only write comments that add value, and if there are fewer comments, they are easier to read and maintain - making it more likely they will be incorrect.</p>
<p>This is an example from an open source pull request:</p>
<pre><code class="language-php">/**
* An interface for field access override.
*/
interface FieldAccessOverrideInterface {
</code></pre>
<p>In my opinion, this doesn't add any value or additional context as it repeats what's already there.</p>
<p>Something I put in my project configuration files is to tweak the coding standards to not check, for example, for class and method docblocks - allowing me to add them where I want and where I think they're needed and add value.</p>
<p>I think this is better than having comments everywhere, and I can focus on the ones that matter.</p>
format: full_html
processed: |
<p>"If you comment everything, people won't read them."</p>
<p>"As soon as one comment is incorrect, the result will be ignored."</p>
<p>These are two comments I heard recently referring to code comments.</p>
<p>If there are too many comments, people will get lost in the information. They won't be able to differentiate boilerplate comments from valuable ones, and as soon as one comment is incorrect, people will assume that others could likely be incorrect too and ignore them.</p>
<p>A solution to these is to only comment what needs to be commented.</p>
<p>Only write comments that add value, and if there are fewer comments, they are easier to read and maintain - making it more likely they will be incorrect.</p>
<p>This is an example from an open source pull request:</p>
<pre><code class="language-php">/**
* An interface for field access override.
*/
interface FieldAccessOverrideInterface {
</code></pre>
<p>In my opinion, this doesn't add any value or additional context as it repeats what's already there.</p>
<p>Something I put in my project configuration files is to tweak the coding standards to not check, for example, for class and method docblocks - allowing me to add them where I want and where I think they're needed and add value.</p>
<p>I think this is better than having comments everywhere, and I can focus on the ones that matter.</p>
summary: null
field_daily_email_cta: { }