oliverdavies.uk/content/node.5dbba89e-cd61-403e-ac30-8bd0cd9e203e.yml

77 lines
4.2 KiB
YAML

uuid:
- value: 5dbba89e-cd61-403e-ac30-8bd0cd9e203e
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:51+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: |
Version-controlled commented-out code
created:
- value: '2022-11-20T00:00:00+00:00'
changed:
- value: '2025-05-11T09:00:51+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: /daily/2022/11/20/version-controlled-commented-out-code
langcode: en
body:
- value: |
<p>Today, whilst debugging some legacy code within an application, I found several blocks of commented-out code.</p>
<p>Some were previous debugging code which had been commented out, and some were old components or previous implementations - but instead of being removed when they were no longer needed, they remained in the codebase as commented-out lines - inactive but adding noise and complexity around the code that I was trying to understand and debug.</p>
<p>To make it easier for me to figure out this code, I'd like it to be as clean to read and as simple to understand as possible.</p>
<p>The codebase is version-controlled, so why would there be a need to comment out and keep the lines?</p>
<p>Version control systems have a log of each change, so if you need to see previous changes, you can view the log and see what changed, when, and by who.</p>
<p>You can also see any other files that were changed in the same commit, and usually, there will be a reference to the issue or ticket that required that change.</p>
<p>If you need to re-add a change that had been removed, you can either do this manually or by reverting the commit.</p>
<p>Should there be commented-out code within a codebase if it's version controlled? I'd say no unless there's a good reason for it to be there and it's providing some additional context or for a specific purpose. If it's an outdated implementation, some old debugging code, or a component that's no longer needed, I think that it should be removed, and people can use version control tools to find or re-introduce those changes if needed.</p>
format: full_html
processed: |
<p>Today, whilst debugging some legacy code within an application, I found several blocks of commented-out code.</p>
<p>Some were previous debugging code which had been commented out, and some were old components or previous implementations - but instead of being removed when they were no longer needed, they remained in the codebase as commented-out lines - inactive but adding noise and complexity around the code that I was trying to understand and debug.</p>
<p>To make it easier for me to figure out this code, I'd like it to be as clean to read and as simple to understand as possible.</p>
<p>The codebase is version-controlled, so why would there be a need to comment out and keep the lines?</p>
<p>Version control systems have a log of each change, so if you need to see previous changes, you can view the log and see what changed, when, and by who.</p>
<p>You can also see any other files that were changed in the same commit, and usually, there will be a reference to the issue or ticket that required that change.</p>
<p>If you need to re-add a change that had been removed, you can either do this manually or by reverting the commit.</p>
<p>Should there be commented-out code within a codebase if it's version controlled? I'd say no unless there's a good reason for it to be there and it's providing some additional context or for a specific purpose. If it's an outdated implementation, some old debugging code, or a component that's no longer needed, I think that it should be removed, and people can use version control tools to find or re-introduce those changes if needed.</p>
summary: null
field_daily_email_cta: { }