oliverdavies.uk/source/_daily_emails/2023-12-24.md

21 lines
613 B
Markdown
Raw Permalink Normal View History

2024-01-03 20:00:00 +00:00
---
title: >
2024-09-08 22:09:54 +00:00
This should never happen
2024-01-03 20:00:00 +00:00
pubDate: 2023-12-24
permalink: >-
daily/2023/12/24/this-should-never-happen
2024-01-03 20:00:00 +00:00
tags:
2024-09-08 22:09:54 +00:00
- software-development
- clean-code
2024-01-03 20:00:00 +00:00
---
How often do you see comments like "This should never happen" in a software codebase?
If that's true, why is it there?
If it truly should never happen, the additional code only adds more noise and distracts from the code that is run.
You can add a test that checks a method isn't called, but what value does this offer?
If it doesn't happen or some code isn't run, remove it and keep it as simple, clean and easy to understand as possible.