uuid: - value: ce877341-4025-4610-89b6-f1f4c9bfe5af 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:00+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: 'Covering icky code with automated tests' created: - value: '2025-03-24T00:00:00+00:00' changed: - value: '2025-05-11T09:00:00+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2025/03/24/icky langcode: en body: - value: |

Every codebase has "icky" code.

Code that works but is difficult to read and understand, that most people will avoid working on.

It could be fragile and occasionally return different results or error.

It could be a suboptimal implementation.

I mention in my test-driven drupal talk when I wrote some code that worked locally but didn't work because of the hosting setup and I had to rewrite the code in a different and less optimal way.

How do you build confidence around this code?

Write more automated tests around it.

This will make it easier to understand what the code does as the tests will act like examples and, as you find situations where the code can break, you can write tests to ensure it works as expected once fixed and will continue to work.

Once there are tests, the code will be easier to add to, change, refactor, read and understand.

format: full_html processed: |

Every codebase has "icky" code.

Code that works but is difficult to read and understand, that most people will avoid working on.

It could be fragile and occasionally return different results or error.

It could be a suboptimal implementation.

I mention in my test-driven drupal talk when I wrote some code that worked locally but didn't work because of the hosting setup and I had to rewrite the code in a different and less optimal way.

How do you build confidence around this code?

Write more automated tests around it.

This will make it easier to understand what the code does as the tests will act like examples and, as you find situations where the code can break, you can write tests to ensure it works as expected once fixed and will continue to work.

Once there are tests, the code will be easier to add to, change, refactor, read and understand.

summary: null field_daily_email_cta: { }