From 33b9594c003f75982f7ac91a3d17e830b761caa2 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 27 Mar 2025 23:30:32 +0000 Subject: [PATCH] Add daily email for 2025-03-24 Covering icky code with automated tests --- source/_daily_emails/2025-03-24.md | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/_daily_emails/2025-03-24.md diff --git a/source/_daily_emails/2025-03-24.md b/source/_daily_emails/2025-03-24.md new file mode 100644 index 000000000..1eaf61345 --- /dev/null +++ b/source/_daily_emails/2025-03-24.md @@ -0,0 +1,33 @@ +--- +title: Covering icky code with automated tests +date: 2025-03-24 +permalink: daily/2025/03/24/icky +tags: + - software-development + - automated-testing + - test-driven-development +cta: ~ +snippet: | + How do you build confidence around icky code? Write automated tests. +--- + +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][0] 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. + +[0]: {{site.url}}/presentations/tdd-test-driven-drupal