Yesterday I wrote about how I was trying to do TDD for a JavaScript project but I got stuck. I'm not stuck any more, thanks to a comment left by Micha

TDD: Getting Out of My Own Way

submited by
Style Pass
2021-05-28 20:00:12

Yesterday I wrote about how I was trying to do TDD for a JavaScript project but I got stuck. I'm not stuck any more, thanks to a comment left by Michael Sprague.

Here's the thing. I wasn't stuck on something technical. And that makes it all the more embarassing that I had spent half of my workday trying to get past it.

I was stuck on something philosophical. I didn't want to do the obvious thing because it seemed messy, which would be orthogonal to "Clean Code". I recently read Uncle Bob's infamous tome and it felt wrong to intentionally write code that I knew I didn't like.

I was forgetting that, "Good code isn't written, it's refactored." This is something that my podcast cohost Ben recently quoted from the last episode of The Bike Shed podcast. I should get this phrase tattoed backwards on my forehead so that I have to look at it in the mirror while I'm brushing my teeth every day.

To recap, I had a module with a helper function that I wanted to be able to test in isolation. I wanted my module to export only the main function, and I found the idea of creating a separate module for the helper function unappealing because I thought that establishing this pattern would result in the number of helper function modules spiraling beyond all bounds of reasonability in no time flat.

Leave a Comment